Android: windowSoftInputMode = "adjustPan" does not work

I have a dumb problem, please follow the pictures below

enter image description here

And when I hit Enter Enter, he saw the pic below,

enter image description here

Now problems arise due to the use of android: windowSoftInputMode = "adjustPan" themes and toolbars for Android Lollipop,

  • The image has been reduced.
  • Email edittext should appear above the keyboard, but it is not.

Suggest some solution.

+8
android keyboard
source share
4 answers

First of all, make sure you specify ScrollView in your xml layout.

 <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" > ... ... </ScrollView> 

Then, inside your activity make sure you do something like this (this code should just demonstrate where to use getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); ):

 public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.temp); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN); final EditText time = (EditText)findViewById(R.id.timeET); time.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { time.requestLayout(); MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED); return false; } }); final EditText date = (EditText)findViewById(R.id.dateET); date.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { date.requestLayout(); MyActivity.this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_UNSPECIFIED); return false; } }); } 
+7
source share

Set the configChanges attribute in the manifest as follows

 <activity android:name="com.xyz.activityName" android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation"/> 

No need to add adjustPan anywhere - in the manifest, either with individual views or with software.

It never allows an input field to hide behind a program panel.

+2
source share

I also add "adjustNothing". My activity in AndroidManifest.xml looks something like this:

 ... <activity android:name=".MainActivity" android:windowSoftInputMode="stateHidden|adjustPan|adjustNothing"> </activity> ... 

It worked for me. Try it yourself.

+1
source share

Make sure windowFullscreen not included in the theme. Check values\Styles.xml for the same.

If you need a full screen, create another theme with the same attributes except windowFullscreen and use it for the required activity.

In Manifest.xml use adjustResize instead of adjustPan

A source

0
source share

All Articles