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 just hiding it. I tried using adjustPan, but it pushes the hole view up (so there is no way to see the top elements of the listview and also de actionbar disappears).
If you take a look at WhatsApp or Line, the functionality is that when the last item of the list is shown at the bottom of the screen, the keyboard pushes up the listview (without taking the action bar or the first elements out of the screen), and when the last item of the list is not shown (after some scrolling up) the keyboard is hidden the bottom list (a normal adjustResize).
Anyone dealed with this issue?
thanks
EDIT:
I'll try to put a visual example:
So lets say this the ListView:
---item 1---
---item 2---
---item 3---
---item 4---
---EditText---
The editText is not part of the ListView, but a LinearLayout aligned at the bottom. When keyboard is shown, the ListView becomes like this (Item 3 and 4 are hidden by Keyboard):
---item 1---
---item 2---
---EditText---
---Keyboard---
and what I would like to get is:
---item 3---
---item 4---
---EditText---
---Keyboard---
I've tried the android:windowSoftInputMode="adjustPan".and the result is that effectivly item 3 and 4 are pushed up and not hidden by keyboard anymore. The problem is that it pushes the listview, but it pushes it out of the screen, so the actionBar disappears, and even if trying to scroll up, I can never see the Item 1 and 2 with the keyboard shown.
Hope I explained myself, not really easy..
Thanks
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
.