Push Listview when keyboard appears without adjustPan

后端 未结 3 1373
清歌不尽
清歌不尽 2020-12-02 18:52

I am trying to create an activity with a listview and a send message at bottom. The problem is that when the keyboard is shown, instead of pushing the bottom content, is jus

相关标签:
3条回答
  • 2020-12-02 18:56

    Single line solution

    list_view.setTranscriptMode(ListView.TRANSCRIPT_MODE_ALWAYS_SCROLL);
    
    0 讨论(0)
  • 2020-12-02 18:58

    In your layout XML:

    android:stackFromBottom="true"
    android:transcriptMode="normal"
    
    0 讨论(0)
  • 2020-12-02 19:10

    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.

    0 讨论(0)
提交回复
热议问题