exception
exception

Reputation: 351

android:windowSoftInputMode="adjustPan" is not working

I have silly problem please follow the below pics

enter image description here

And when i clicked on Enter Email it saw like below pic,

enter image description here

Now the problems are coming inspite of using android:windowSoftInputMode="adjustPan" android Lollipop theme and toolbar,

  1. Image became smaller.
  2. Email edittext should have shown above keyboard, but it did not.

Suggest some solution.

Upvotes: 16

Views: 31746

Answers (5)

Sangeetha
Sangeetha

Reputation: 11

just add in android manifest.xml

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

Upvotes: 1

Prabs
Prabs

Reputation: 5163

Make sure windowFullscreen isn't included in the theme. Check values\Styles.xml for the same.

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

In Manifest.xml use adjustResize instead of adjustPan

Source

Upvotes: 4

Akeshwar Jha
Akeshwar Jha

Reputation: 4576

Set the configChanges attribute in your manifest as follows

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

No need to add adjustPan anywhere -neither in the manifest, nor with the individual views and neither programmatically.

It never lets the input field hide behind the softkeyboard.

Upvotes: 8

Liem Nguyen
Liem Nguyen

Reputation: 19

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

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

It worked for me. Please try yourself.

Upvotes: 2

Sash_KP
Sash_KP

Reputation: 5591

First of all make sure you have provided a 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 are doing something like this(this code is just to 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;
        }
    });
     }

Upvotes: 10

Related Questions