16

I have a listView that expands upwards instead of downwards. I have another listView on another page that works just fine and populates itself from the top -> bot. Why does my listView start from the bottom instead of the top?

My XML `

<ListView
    android:id="@+id/list_view_showRegister"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/showRegister"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="50dp"
    android:clickable="false" >

</ListView>`
NiklasHansen
  • 269
  • 1
  • 2
  • 14
  • What exactly is your question? Also, try to add more tags like "android" ;-) Welcome to stackoverflow. – siebz0r Nov 07 '12 at 13:04
  • Just noticed that I didnt ask any question, Im just wondering why my listView is populating itself from the bottom and up. I want it to expand downwards. Thanks :) – NiklasHansen Nov 07 '12 at 13:07

3 Answers3

27

Your ListView is still actually populating from the top downwards. Just not from the top of the page.

You have set the layout_height="wrap_content" and the layout_above="@+id/showRegister". With the height being wrap_content, the view will only be as large as it's contents. Then, due to the fact you have used layout_above, it will be directly above another view.

The listview is not filling from the bottom, it is filling from the top (of the listview) - but the listview itself is only starting from halfway up the screen. Anything above the listview is not actually part of the listview, but empty space instead.

The solution is to either set the layout_height="match_parent", or remove the layout_above tag.

I know this is an old question but I hope this helps anyone else who may have found this issue via google.

Mike Baxter
  • 6,868
  • 17
  • 67
  • 115
9

See for android:stackFromBottom attribute.

Jin35
  • 8,602
  • 3
  • 32
  • 52
9

Have a look a these links. Is it possible to make a ListView populate from the bottom?. populating from bottom. Add new items to top of list view on Android?. Add new item at the top of list.

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256