[Solved] Move layouts up when soft keyboard is shown?

I have a few elements in a RelativeView with the align bottom attribute set, when the soft keyboard comes up the elements are hidden by the soft keyboard.

I would like them to move up so that if there is enough screen space they are shown above the keyboard, or to make the section above the keyboard scrollable so the user can still see the elements.

Any ideas on how to approach this?

Enquirer: Dinedal


Solution #1:

Yes, check out this article on the Android developers’ site which describes how the framework handles the soft keyboard appearing.

The android:windowSoftInputMode attribute can be used to specify what happens on a per-activity basis: whether the layout is resized or whether it scrolls etc.

Respondent: Christopher Orr

Solution #2:

You can also use this code in onCreate() method:

Respondent: Bobs

Solution #3:

Add in AndroidManifest.xml for your activity:

Respondent: Serhii Bohutskyi

Solution #4:

Make changes in the activity of your Manifest file like



Make changes in your onCreate() method in the activity class like

Respondent: Jose Kurian

Solution #5:

similar issue i was facing with my layout which consist scroll view inside.
Whenever i try to select text in EditText,Copy/Cut/Paste action bar gets moved up with below code as such it does not resize layout


By modifying it to as below

1) AndroidManifest.xml


2) style.xml file ,in activity style

<item name="android:windowActionBarOverlay">true</item>

It worked.!!!!!!!!!!!!

Respondent: Ronak Poriya

Solution #6:

In AndroidManifest.xml, don’t forget to set:


and for RelativeLayout inside ScrollView ,set :

 android:layout_gravity="center" or android:layout_gravity="bottom" 

it will be okay

Respondent: Zahra.HY

Solution #7:

for Activity in its oncreate methode insert below line


and for fragments in its onCreate method

Respondent: Rahul_Pawar

Solution #8:

There are 3 steps to follow to scroll screen up.

  1. Write in manifest file for your activity:


  1. Add following line in oncreate() method of your activity


  1. Then place your whole view in “Scrollview” in XML file like :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_gravity="center" >
        <TextView />
        <TextView />
        <EditText >
            <requestFocus />
        <Button />

P.S. Don’t forget to add android:layout_gravity=”center” in parent Relative layout.

Respondent: Heena Arora

Solution #9:

<activity name="ActivityName"

Add NestedScrollView around layout which you want to scroll, this will perfectly work

Respondent: Prakash Reddy

Solution #10:

I tried a method of Diego Ramírez, it works.
In AndroidManifest:


In activity_main.xml:

<LinearLayout ...

    android:layout_weight="1" />

    android:inputType="textPersonName" />

<EditText ...>
Respondent: CoolMind

Solution #11:

I have found a solution to my problems that it’s pretty same as yours.

First of all, I only have a LinearLayout with 2 elements, an ImageView and a LinearLayout wich contains 2 EditText and one Button, so I needed to keep them separate in full screen without keyboard, and when the keyboard appears they should look closer.

So I added the view between them with the height attribute in 0dp and weight 1, that let me keep my views separate one form each other. and when the keyboard appers, as they don’t have a fix height, they just resize and keep the aspect.

Voila! The layout resize and the distance between my views is the same when the keyboard is or not present.

Solution #12:

In your manifest file add the below line. It will work

<activity name="MainActivity"
Respondent: Shivam Garg

Solution #13:

I just added the following line to the top level layout and everything worked:

Respondent: Darush

Solution #14:

  1. If user want this task using manifest then add this line in manifest
  2. In manifest add this line: – android:windowSoftInputMode=”adjustPan”

In Java File or Kotlin File (Programmatically):- If the user wants this using Activity then add the below line in onCreate Method

Respondent: safal bhatia

Solution #15:

Here is full manifest code

            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
Respondent: Dantalian

Solution #16:

if you are in fragments then you have to add the below code to your onCreate on your activity it solves issue for me

getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

Solution #17:

Alright this is very late however I’ve discovered that if you add a List View under your edit text then the keyboard will move all layouts under that edittext without moving the ListView



    android:layout_height="match_parent"//can make as 1dp
    android:layout_below="@+id/et" // set to below editext
**<any layout**

This is the only solution that worked for me.

Respondent: Omar Boshra

Solution #18:

Not a single advice solve my issue. Adjust Pan is almost as like work Adjust Resize. If i set Adjust Nothing than layout not move up but it hide my edittext of bottom that i am corrently writing. So after 24 hour of continuous searching I found this source and it solve my problem.

Solution #19:

It might be late but I want to add few things.
In Android Studio Version 4.0.1, and Gradle Version 6.1.1, the windowSoftInputMode will not work as expected if you are adding the following flags in your Activity :


After wasting lot of time, I have found that hack. In order for adjustResize or AdjustPanor any attribute of windowSoftInputMode to work properly, you need to remove that from your activity.

Respondent: Sharryy

Solution #20:

Use Scroll View as a Parent and use this Tag in Scroll View


Solution #21:

This is what worked for me after looking at a lot of solutions:

  1. AndroidManifest.xml



    to an activity

  2. style.xml file,in activity style

    <item name="android:windowActionBarOverlay">true</item>

Props to this post:
Scroll entire layout up when keyboard is shown

Respondent: Martin Vichev

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published. Required fields are marked *

New ride at Perth's Adventure World a ‘swing on steroids’ - Australasian Leisure Management npp pharma the truth about anabolic steroid drugs and professional sports