Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ListView items aligned on top

I have an Android ListView.

<ListView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/myListView"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" >

Sometimes it contains only a few items, sometimes just one.

When this is the case, these few items are centered on the listview. But I want the items start from the top and not be centered.

How to do it?

like image 697
juergen d Avatar asked Dec 12 '25 01:12

juergen d


1 Answers

android:layout_centerVertical="true"
android:layout_centerHorizontal="true"

above 2 lines made your listview to center of its parent.hence you got items are centered on the listview.

Can you remove android:layout_centerVertical="true" from your code and try again?

like image 139
Nitesh Avatar answered Dec 14 '25 16:12

Nitesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!