How to move the layout up when the soft keyboard is shown android

AndroidAndroid Softkeyboard

Android Problem Overview


I have a login screen with two EditTexts and a login button in my layout. The problem is that, when I start typing, the soft keyboard is shown and covers the login button. How can I push the layout up or above the keyboard when it appears?

I do not want to use a ScrollView, just want to implement it without scrolling down. Please, suggest me some way of doing it. Thanks in advance.

Android Solutions


Solution 1 - Android

Set windowSoftInputMode property to adjustPan and adjustResize

<activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>

Solution 2 - Android

Try this in the android manifest file corresponding to the activity.

<activity android:windowSoftInputMode="adjustPan"> </activity>

Solution 3 - Android

Use this code in onCreate() method:

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

Solution 4 - Android

only

android:windowSoftInputMode="adjustResize"

in your activity tag inside Manifest file will do the trick

Solution 5 - Android

Put this line in activity declaration time in manifest.xml

<android:windowSoftInputMode="adjustPan">

Solution 6 - Android

I somehow achieved this by knowing the status of the soft keyboard on the device. i move the layout to y position when the keyboard is shown and moved back to its original position when not shown. this works fine, followed this guidelines.

Solution 7 - Android

android:fitsSystemWindows="true"

add property on main layout of layout file and

android:windowSoftInputMode="adjustResize"

add line in your Manifest.xml file on your Activty

its perfect work for me.

Solution 8 - Android

Put this in your activity declaration in manifest file <activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity>

or if you want you can add in onCreate() method of your activity

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

Solution 9 - Android

This is all that is needed:

<activity android:windowSoftInputMode="adjustResize"> </activity>

Solution 10 - Android

Accoding to this guide, the correct way to achieve this is by declaring in your manifest:

<activity name="EditContactActivity"
        android:windowSoftInputMode="stateVisible|adjustResize">
        
    </activity>

Solution 11 - Android

When the softkeyboard appears, it changes the size of main layout, and what you need do is to make a listener for that mainlayout and within that listener, add the code scrollT0(x,y) to scroll up.

Solution 12 - Android

If you are working with xamarin, you can put this code WindowSoftInputMode =Android.Views.SoftInput.AdjustPan | Android.Views.SoftInput.AdjustResize in activity attribute of the MainActivity class. For example, now the activity attribute will look like below

    [Activity(WindowSoftInputMode =Android.Views.SoftInput.AdjustPan | Android.Views.SoftInput.AdjustResize)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    {
        //some code here.
    }

Solution 13 - Android

I solve this by adding code into manifest:

<activity android:name=".Login"
        android:fitsSystemWindows="true"
        android:windowSoftInputMode="stateHidden|adjustPan"
</activity>

Solution 14 - Android

You should use

android:windowSoftInputMode="adjustPan|stateHidden"

in your AndroidManifest.xml file where you are declaring your activity. This will adjust your layout contents, when keyboard is shown in the layout.

Solution 15 - Android

Make use of Relative layout it will adjust the view so that you can see that view while typing the text

Solution 16 - Android

This works like a charm for me

getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

Solution 17 - Android

This will definitely work for you.

android:windowSoftInputMode="adjustPan"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncavalloView Question on Stackoverflow
Solution 1 - AndroidjeetView Answer on Stackoverflow
Solution 2 - AndroidjencyView Answer on Stackoverflow
Solution 3 - AndroidBobsView Answer on Stackoverflow
Solution 4 - AndroidBhargav ThankiView Answer on Stackoverflow
Solution 5 - AndroidDayanand WaghmareView Answer on Stackoverflow
Solution 6 - AndroidcavalloView Answer on Stackoverflow
Solution 7 - AndroidKalsariya DevindraView Answer on Stackoverflow
Solution 8 - AndroidPradnya KanaseView Answer on Stackoverflow
Solution 9 - AndroidBollingView Answer on Stackoverflow
Solution 10 - AndroidDavid_EView Answer on Stackoverflow
Solution 11 - AndroidDila GurungView Answer on Stackoverflow
Solution 12 - AndroidTushar patelView Answer on Stackoverflow
Solution 13 - AndroidSandeep SanklaView Answer on Stackoverflow
Solution 14 - AndroidFarhan GhaffarView Answer on Stackoverflow
Solution 15 - AndroidMaheshView Answer on Stackoverflow
Solution 16 - AndroiddroidchefView Answer on Stackoverflow
Solution 17 - Androidsanjay kumarView Answer on Stackoverflow