Reputation: 599
I have a simple application which basically consists of a line of buttons and a ListView of items to be selected and manipulated. There might be only one item in the list or a few. However, I would prefer if the list would populate from the bottom of the ListView, since the way most people hold their phones makes it easier to select items closer to the bottom of the screen. Is this possible?
Upvotes: 45
Views: 21254
Reputation: 39
These are a must tags for the reverse populating of the list view.
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:stackFromBottom="true"
</ListView>
Upvotes: 0
Reputation: 85
I tried android:stackFromBottom="true"
with android:layout_width="match_parent"
android:layout_height="fill_parent"
but it didn't work
finally
Adapter.insert(post,0);
saved my day. Here post is the class which is returning data to be added
Upvotes: 0
Reputation: 2243
You can have the ListView
stack its items from the bottom up using a simple XML property
under the xml -
<ListView
android:stackFromBottom="true"
...
></ListView>
Please read @The Berga answer to otherwise this won't work.
Upvotes: 125
Reputation: 3804
Joe answer is correct but it's important to point out that it only works if the ListView
's width and height are set to match_parent
or fill_parent
.
If set to wrap_content
it still will populate from top to bottom.
Upvotes: 19