简体   繁体   中英

Add ListView items to bottom of list first

I am building an android application that implements chat functionality. I currently the chat works. However the first messages are appearing at the top of the ListView I would like to make the chat grow from the bottom to the top as opposed to grow from the top down. Is this possible to do? I know apps such as Periscope and Meerkat both do this but I am not sure if it is with a ListView

Set listView.setStackFromBottom(true); for your ListView.

From the doc : public void setStackFromBottom (boolean stackFromBottom)

When stack from bottom is set to true, the list fills its content starting from the bottom of the view

in addition to dhaval patel's answer. you can also set transcript mode to always scroll if you want your listview to automatically scroll down to bottom whenever the notifydatasetchanged is called. if you don't want that, you can just set the transcriptmode to normal. you can just code it via xml of your listview

android:stackFromBottom="true"
android:transcriptMode="alwaysScroll"

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