Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 790
exception Avatar asked Jan 09 '15 04:01

exception


5 Answers

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;
        }
    });
     }
like image 61
Sash_KP Avatar answered Nov 12 '22 13:11

Sash_KP


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.

like image 29
Akeshwar Jha Avatar answered Nov 12 '22 14:11

Akeshwar Jha


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

like image 4
Prabs Avatar answered Nov 12 '22 13:11

Prabs


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.

like image 2
Liem Nguyen Avatar answered Nov 12 '22 13:11

Liem Nguyen


just add in android manifest.xml

<activity
   android:name=".MainActivity"
   android:windowSoftInputMode="adjustPan|adjustNothing">
</activity>
like image 1
Sangeetha Avatar answered Nov 12 '22 13:11

Sangeetha