Push Listview when keyboard appears without adjustPan

空扰寡人 提交于 2019-11-27 11:54:57

Okay I have found a solution for you, what you want to do is essentially have the ListView scroll to the bottom every time. You can do this by:

ListView l = getListView();
l.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
l.setStackFromBottom(true);

If it is an Activity, do it in onCreate. If it is a Fragment, do it in onViewCreated.

s0i1

In your layout XML:

android:stackFromBottom="true"
android:transcriptMode="normal"

Single line solution

list_view.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!