I have a vertical sliding drawer at the bottom of my app. When the soft keyboard opens, it pushes the tab for the drawer up, so it sits atop the keyboard. I actually want it to remain at the bottom of the screen, becoming hidden when the keyboard is shown.

Anyone else run into this issue? Know how to fix it?

Solution 1

You can simply switch your Activity's windowSoftInputModeflag to adjustPan in your AndroidMainfest.xml file inside your activity tag.

Check the official documentation for more info.


If your container is not changing size, then you likely have the height set to "match parent". If possible, set the parent to "Wrap Content", or a constraint layout with constraingts to top and bottom of parent.

The parent container will shrink to fit the available space, so it is likely that your content should be inside of a scolling view to prevent (depending on the phone manufacturer and the layout choosen...)

  1. Content being smashed together
  2. Content hanging off the screen
  3. Content being inacccessable due to it being underneath the keyboard

even if the layout it is in is a relative or constraint layout, the content could exhibit problems 1-3.

Solution 2

None of the answers worked for me, but this did the trick, add this attribute to the activity tag in your AndroidManifest.xml:


Solution 3

In my case, the reason the buttons got pushed up was because the view above them was a ScrollView, and it got collapsed with the buttons pushed up above the keyboard no matter what value of android:windowSoftInputMode I was setting.

I was able to avoid my bottom row of buttons getting pushed up by the soft keyboard by setting android:isScrollContainer="false" on the ScrollView that sits above the buttons.

Solution 4

You can try to add this attribute dynamically, by putting the following code in the onCreate method of your activity:


This worked for me, but that:



Solution 5

These answers here didn't help me. So I tried this:


This worked like a charm, Now the header of my app doesn't disappear. Its smoother.

Solution 6

To do this programatically in a fragment you can use following code


Place this in onResume()

Solution 7

This one worked for me


Solution 8

Just a single line to be added...

Add android:windowSoftInputMode="stateHidden|adjustPan" in required activity of your manifest file.

I just got solved :) :)

Solution 9

For future readers.

I wanted specific control over this issue, so this is what I did:

From a fragment or activity, hide your other views (that aren't needed while the keyboard is up), then restore them to solve this problem:

            rootView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                public void onGlobalLayout() {
                    Rect r = new Rect();
                    int heightDiff = rootView.getRootView().getHeight() - (r.bottom - r.top);

                    if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...
                    //ok now we know the keyboard is up...

                    //ok now we know the keyboard is down...


Solution 10

So far the answers didn't help me as I have a button and a textInput field (side by side) below the textView which kept getting hidden by the keyboard, but this has solved my issue:


Solution 11

For xamarin users add this code to Activity attribute of the MainActivity class,

WindowSoftInputMode =Android.Views.SoftInput.AdjustNothing

or you can add this code Window.SetSoftInputMode(Android.Views.SoftInput.AdjustNothing) to the OnCreate method of MainActivity class.

Solution 12

This was the best which worked for me


Try it!

Solution 13

Add following code to the 'activity' of Manifest file.


Solution 14


This code works.

Solution 15

Well i have watched these answers but in my case i fell into the same issue and got refuge through a very handy and easiest solution that involves putting a very small innocent attribute in your Scrollview tag residing in your xml file. That is


Good luck!

Solution 16


This one is working for me.

Solution 17

I have solved my issue by adding


In manifest file add.

and making the Recyclerviews constraint isScrollContainer to false .


Solution 18

Try to use this:


Solution 19

For Scroll View:

if after adding android:windowSoftInputMode="stateHidden|adjustPan" in your Android Manifest and still does not work.

It may be affected because when the keyboard appears, it will be into a scroll view and if your button/any objects is not in your scroll view then the objects will follow the keyboard and move its position.

Check out your xml where your button is and make sure it is under your scroll View bracket and not out of it.

Hope this helps out. :D

Solution 20

In my case I needed the keyboard to stay hidden and just after the click of the button my layout needs to be adjusted, so I just added this command in the manifest and it got super right.


Solution 21

When you want to hide view when open keyboard.

Add this into your Activity in manifest file


Solution 22

None of them worked for me, try this one

 private void scrollingWhileKeyboard() {
    drawerlayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        public void onGlobalLayout() {

            Rect r = new Rect();
            try {
                int screenHeight = drawerlayout.getRootView().getHeight();
                int keypadHeight = screenHeight - r.bottom;
                if (keypadHeight > screenHeight * 0.15) {
                } else {
            } catch (NullPointerException e) {



Solution 23

I was struggling for a while with this problem. Some of the solutions worked however some of my views where still being pushed up while others weren't... So it didn't completely solve my problem. In the end, what did the job was adding the following line of code to my manifest in the activity tag...


Good luck

Solution 24

The activity's main window will not resize to make room for the soft keyboard. Rather, the contents of the window will be automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing.


This might be a better solution for what you desired.

Solution 25

This code may help you. Use it in your oncreate method.


Solution 26

Include in your manifest file under activity which you want to display .But make sure not using Full screen Activity


Solution 27

@manifest in your activity:


Solution 28

There are two ways of solving this problem. Go to the AndroidManifist.xml, and in the name of your activity, add this line


As in the below code, I have added to the Register Activity.

 <activity android:name=".Register"

In the second way, go to your activity, and in your onCreate method, add this code.