简体   繁体   中英

Why is my ListView begins from the bottom to top?

I have a listview of products whos adding one by one to an ArrayList from the DataBase. The order of adding and the listview are equals (so that's ok).

My problem is that the products are shows from the middle of the page (i have to scroll down a lot to see them). listview display My 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>

thank you.

Replace this line in your ListView

android:layout_height="457dp"

with this line

android:layout_height="match_parent"

With match_parent you fill the whole screen with your ListView not only 457dp .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM