android - 为什么我的ListView是从下往上开始的?

标签 android xml android-studio listview

我有一个产品 ListView ,它正在将数据库中的一个一个添加到 ArrayList。 添加的顺序和 ListView 是相等的(所以没关系)。

我的问题是产品显示在页面中间 (我必须向下滚动很多才能看到它们)。 listview display 我的 XML:

<ListView
    android:id="@+id/listviewmanager"
    android:layout_width="fill_parent"
    android:layout_height="457dp"
    android:layout_alignParentLeft="true"
    android:clickable="false"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.0"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintVertical_bias="1.0" >

    <ScrollView
        android:id="@+id/scrollView2"
        android:layout_width="match_parent"
        android:layout_height="474dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.0"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" />
    </ScrollView>
</ListView>

谢谢。

最佳答案

在您的 ListView 中替换这一行

android:layout_height="457dp"

用这条线

android:layout_height="match_parent"

使用 match_parent,您可以用 ListView 填充整个屏幕,而不仅仅是 457dp

关于android - 为什么我的ListView是从下往上开始的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53973977/

相关文章:

android - BroadcastReceiver 在连接状态更改时使 Android 应用程序崩溃

java - 无法在 Maven 项目中运行 TestNG 测试套件

android - 使用最新gradle升级到androidstudio 3.4.1-> processReleaseManifest错误

java - 在 web.xml 中添加 servlet

java - 什么是 org.xml.sax.SAXException : Scanner State 24 not Recognized?

android - 错误 : "Only the Kotlin standard library is allowed to use the ' kotlin' package"

java - 不确定如何解决 "Cannot resolve constructor"错误

android - Android中如何处理非常非常大的数据?

Android:未经许可的来电监听器

android - 如何截断 Realm android中的所有表