Is there any way to change android:windowSoftInputMode value from java class?
Use the following to change the softInputMode for an Activity.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Use the following to change the softInput type for an EditText.
mEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
Thanks to @Eliezer for correction
How to set windowSoftInputMode programmatically on different screens in react-native?
Try this component react-native-android-keyboard-adjust
When the component in which you don't want to move up views mounts, set AndroidKeyboardAdjust.setAdjustPan()
and when that component unmount reset it to AndroidKeyboardAdjust.setAdjustResize()
or whatever option that suits your criteria
See this answer
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
Using adjustPan or adjustResize specific to a fragment
You can change the behavior programmatically, see this answer for that.
So what I would do: if fragment A is resumed, use getActivity()
to get a reference to its parent activity, and then use the command from the question to change the behavior.
Then do the same with fragment B, but use the other parameter when setting the soft input mode behavior.
adjustResize
would be:WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
adjustPan
would be:WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN
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.
Android - ScrollView activity hosted in TabActivity and windowSoftInputMode
In the absence of any direct solution for this, I have resorted to a kind of hack. I have set my TabHost activity to adjustResize
and then written code to hide/unhide the tab bar controls (TabWidget) when the soft keyboard appears/disappears. I managed to get a pretty good result in the end, using the technique here : Adjust layout when soft keyboard is on to detect the keyboard appearing/disappearing.
Related Topics
Remove Unwanted White Space in Webview Android
How to Get Results from an Intentservice Back into an Activity
Android Studio: "Use Default Gradle Wrapper" VS. "Use Customizable Gradle Wrapper"
How to Take Pictures from The Camera Without Preview When My App Starts
How to Display a One Time Welcome Screen
How to Add Cardview in Layout Xml in Androidx
How to Get The Dimensions of a Drawable in an Imageview
How to Get Total Ram Size of a Device
Get The Displayed Size of an Image Inside an Imageview
How to Implement Ssl Certificate Pinning While Using React Native
Help with a Custom View Attributes Inside a Android Library Project
Google Maps Android API V2 - Sample Code Crashes
How to Set Android Tablayout in The Bottom of The Screen
Evenly Spaced Menu Items on Toolbar
How to Replace a String for a Buildvariant with Gradle in Android Studio
Fragment in Viewpager Not Restored After Popbackstack
How to Find The Amount of Free Storage (Disk Space) Left on Android