android - How to auto scroll up the chat messages (using recyclerview instead of listview) above the softkeypad whenever keypad pop ups? -
like in chat applications whenever want send messages soft keypad pop ups auto scroll last seen messages top of soft keypad provided nothing hidden behind soft keypad. in case keypad hides conversations. how fix issue , have used recycler view displaying messages. used android.support.v7.widget.recyclerview
with recyclerview can achieve follows:
linearlayoutmanager linearlayoutmanager = new linearlayoutmanager(this); linearlayoutmanager.setreverselayout(true); recyclerview.setlayoutmanager(linearlayoutmanager);
this block of code tell recyclerview scroll relative bottom of list shows messages in reverse order in code if getting messages database, read them last message this:
cursor c = ...; c.movetolast(); do{ //your code gets messages cursor... }while(c.movetoprevoius());
and when want add new message list add them this:
//arraylist messages messages.add(0, message);
Comments
Post a Comment