android:windowSoftInputMode=adjustResize doesn't make any difference?
I created a new project in order to try and get the basic features working for window resizing and the slowly moved it towards the target peice of my project. Doing this I tracked the problem down to this:
In my theme hierarchy I had this property:
<item name="android:windowFullscreen">true</item>
which was burried at the level of Theme.Black.NoTitleBar.FullScreen
- An ancestor of my custom theme.
The documentation suggests that this is a "Flag indicating whether this window should fill the entire screen". That sounds like a good thing to have if you have an app which takes up the whole screen... Except it still takes up the whole screen without the flag.
In fact, once you've taken this out, there is absolutely no change in the app at all... apart from adjustResize
now works perfectly.
Difference between adjustResize and adjustPan in android?
From the Android Developer Site link
"adjustResize"
The activity's main window is always resized to make room for the soft
keyboard on screen."adjustPan"
The activity's main window is not resized to make room for the soft
keyboard. Rather, the contents of the window are automatically panned
so that the current focus is never obscured by the keyboard and users
can always see what they are typing. This is generally less desirable
than resizing, because the user may need to close the soft keyboard to
get at and interact with obscured parts of the window.
according to your comment, use following in your activity manifest
<activity android:windowSoftInputMode="adjustResize"> </activity>
android:windowSoftInputMode=adjustPan is not working
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;
}
});
}
windowSoftInputMode=adjustResize not working with translucent action/navbar
You are missing the following property:
android:fitsSystemWindows="true"
in the root RelativeLayout
of the fragment .xml layout.
Update:
Last year there was an interesting talk by Chris Bane that explains in good detail how this works:
https://www.youtube.com/watch?v=_mGDMVRO3iE
Android: windowSoftInputMode=“adjustResize” has no effect on the UI
Use adjustPan so the screen can be translated.
Or put all fields of your screen into the ScrollView so the area can be reduced.
android:windowSoftInputMode=adjustResize is not working as it should be
Remove your outer Linear Layout and place everything inside a Relative Layout. And align your bottom edit text to bottom of the layout by making alignParentBottom true.
And main thing "Dont do anything to the android:windowSoftInputMode." Delete that line from manifest file.
Let android take default.
Why doesn't my layout move up enough with adjustPan?
create an object like InputMethodManager methodManager at class level.
add these lines to your onCreate()
method,
methodManager = (InputMethodManager) this.getSystemService(this.INPUT_METHOD_SERVICE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
and in your onClick() method, show keyboard like,
methodManager.toggleSoftInputFromWindow(
your_view_name.getApplicationWindowToken(),
InputMethodManager.SHOW_FORCED, 0);
If this word getApplicationWindowToken throws an error then replace it with getWindowToken
hope it helps.
Related Topics
How to Add External Fonts to Android Application
Whatsapp Message Layout - How to Get Time-View in the Same Row
Android Gradle: Buildtoolsversion VS Compilesdkversion
Android: Last Line of Textview Cut Off
Monitor Network Activity in Android Phones
How to Get a Jacoco Coverage Report Using Android Gradle Plugin 0.10.0 or Higher
Android: Need to Record Mic Input
Mask Imageview with Round Corner Background
React-Native, Android, Genymotion: Adb Server Didn't Ack
How to Instantiate Application Com.Android.Tools.Fd.Runtime.Bootstrapapplication Android
Googleplayservicesutil VS Googleapiavailability
How to Implement an Android:Background That Doesn't Stretch
Seekbar and Media Player in Android
Adding Fling Gesture to an Image View - Android