How to move layout when Android soft keyboard is displayed

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

I don't want to use ScrollView , I just want to implement it without scrolling down. Please suggest me some way to do this. Thanks in advance.

+78
android android-softkeyboard
Feb 02 '12 at 11:50
source share
15 answers

i somehow achieved this, knowing the state of the soft keyboard on the device. I move the layout to y position when the keyboard is displayed and returns to its original position when it is not shown. this works fine, follow the recommendations from / questions / 16169 / how-to-check-visibility-of-software-keyboard-in-android / 118696 # 118696

+10
Feb 06 2018-12-12T00:
source share

Set the SoftInput Mode property of the Window to configure Pan and adjustResize

 <activity android:windowSoftInputMode="adjustPan|adjustResize"> </activity> 
+61
02 Feb 2018-12-12T00:
source share

Try this in the Android manifest file corresponding to the action.

 <activity android:windowSoftInputMode="adjustPan"> </activity> 
+28
Feb 02 '12 at 12:27
source share

Use this code in the onCreate() method:

 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 
+23
Feb 25 '13 at 9:11
source share

only

 android:windowSoftInputMode="adjustResize" 

in your activity tag inside the manifest file will do the trick

+14
Sep 23 '15 at 5:38
source share

Put this line during activity declaration in manifest.xml

 <android:windowSoftInputMode="adjustPan"> 
+11
Jan 15 '15 at 9:50
source share

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

or if you want, you can add to the onCreate () method of your activity

 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); 
+6
May 28 '15 at 14:35
source share
 android:fitsSystemWindows="true" 

add a property to the main location of the layout file and

 android:windowSoftInputMode="adjustResize" 

add a line to your Manifest.xml file to your Activity

his perfect job for me.

+4
Oct 21 '16 at 5:20
source share

This is all that is needed:

 <activity android:windowSoftInputMode="adjustResize"> </activity> 
+3
Feb 25 '15 at 12:59
source share

Agreeing with this guide , the correct way to achieve this is to declare in your manifest:

 <activity name="EditContactActivity" android:windowSoftInputMode="stateVisible|adjustResize"> </activity> 
+2
Mar 14 '14 at 21:14
source share

When the on-screen keyboard appears, it resizes the main layout, and you need to do this to listen to this main one and inside this listener, add the code scrollT0(x,y) to scroll up.

+2
Nov 07 '15 at 10:58
source share

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

  [Activity(WindowSoftInputMode =Android.Views.SoftInput.AdjustPan | Android.Views.SoftInput.AdjustResize)] public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity { //some code here. } 
+2
Jun 10 '16 at 5:20
source share

Use the Relative layout, it will adjust the view so you can see this view as you type

0
Feb 03 2018-12-12T00:
source share

It works like a charm to me

 getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); 
0
Aug 01 '14 at 2:03
source share

you should use "android: windowSoftInputMode =" adjustPan | stateHidden "in your android Mainfest.xml file where you declare its activity. This will allow you to adjust the contents of the layout when the keyboard is displayed in the layout.

0
May 17 '16 at
source share



All Articles