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

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

Posted by: admin November 30, 2017 Leave a comment

Questions:

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.

Answers:

Set Window SoftInput Mode property to adjustPan and adjustResize

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

Questions:
Answers:

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

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

Questions:
Answers:

Use this code in onCreate() method:

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

Questions:
Answers:

only

android:windowSoftInputMode="adjustResize"

in your activity tag inside Manifest file will do the trick

Questions:
Answers:

Put this line in activity declaration time in manifest.xml

<android:windowSoftInputMode="adjustPan">

Questions:
Answers:

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 the guidelines from https://stackoverflow.com/a/4737265/1063861

Questions:
Answers:

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);

Questions:
Answers:
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.

Questions:
Answers:

This is all that is needed:

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

Questions:
Answers:

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

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

    </activity>

Questions:
Answers:

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.

Questions:
Answers:

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.
    }

Questions:
Answers:

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

Questions:
Answers:

This works like a charm for me

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

Questions:
Answers:

you should use “android:windowSoftInputMode=”adjustPan|stateHidden” in your android Mainfest.xml file where you are declaring her activity. This will adjust your layout contents, When keyboard show in layout.