I have an app that has 4 Fragment
s (displayed as tabs), and all of them share the same split Action Bar
. The top bar has the tabs' buttons and the bottom bar has the actions' buttons. There's one Fragment
that has an EditText
at the top and a ListView
under it.
Now, the problem with the keyboard in this Fragment
is:
if I use adjustPan
to make the keyboard cover the bottom bar, the ListView
doesn't get resized, so some of its elements get covered by the keyboard and I can't scroll to see them;
if I use adjustResize
, the ListView
does get resized, but the bottom bar gets pushed up, of course. I don't want that.
What I'd like is that the bottom bar gets covered by the keyboard AND the ListView
gets resized so that I can see all of its elements by scrolling.
In the meantime, I'm going to use adjustPan
and make the keyboard disappear when the user touches the ListView
, but I'd like to find a way to make what I explained above.
Is it a bad idea to try to resize the ListView
programmatically when the keyboard appears (while using adjustPan
)? Or is there a way to hide (with setVisibility(View.GONE)
or something) the bottom bar while using adjustResize
? And lastly, is there an easy way to understand when the keyboard appears and to get its height?
Thanks for the help.
P.S. I've already found all the few similar questions, and none of them have a solution.
The one thing I could think of is setting the softInputMethodMode to adjustResize then showing or hiding the bottom bar when the keyboard closes and opens. Although there aren't any keyboard open/close events to listen to, you can detect it by observing changes in the window height. You can achieve this by adding a global layout listener to your main content view's view tree observer. Check out this post for an explanation and code of using a view tree observer.
Edit
Here's a snippet that I copied from the link above with relevant changes (I haven't tried this out, but it highlights the idea) :