Android - How to resize only certain views when keyboard visibility changes

581 views Asked by At

I have an Activity with three Fragment and they are controlled by Tabs at the bottom.

One of the fragments needs the keyboard and so I would like to resize the fragment recycler view when the keyboard is visible, so that the last item in the recycler view is visible above the keyboard (after scrolling).

But if in the AndroidManifest.xml, I specify

android:windowSoftInputMode="adjustResize"

or

android:windowSoftInputMode="adjustPan"

The bottom tabs also become visible above the keyboard.

I even tried to use OnGlobalLayoutListener to check when the keyboard is visible and then adjust height of the recycler view accordingly. But this also does not work, since, OnGlobalLayoutListener is called only when android:windowSoftInputMode="adjustPan" or android:windowSoftInputMode="adjustResize" are used, which defeats the purpose in this case.

Is there any way such that the view of the Fragment is resized/adjusted but not the activity view (bottom tabs)?

Thanks

1

There are 1 answers

1
Sunny On BEST ANSWER

So this is how I solved it.

The keyboard changes are received in OnGlobalLayoutListener when

android:windowSoftInputMode="adjustPan"

And it also does not push the bottom tabs above the keyboard.

Thus, it solves the issue at hand.

Thanks