Different WindowSoftInputMode for activity and fragment - android

I want to achieve the functionality shown in the image. Let me explain the scenario in details.
I have a main activity and several fragments. what I want is when the keyboard is open the activity will remain same (will not resize) but the fragment will change its height and will be shown above the keyboard.
I have tried to do this using android:windowSoftInputMode="adjustResize" and android:windowSoftInputMode="adjustPan" for activity and getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); in onCreateView of the fragment. But its not working properly. I am getting this.
is there any way to solve this?

Related

Android: the soft keyboard is hiding the EditText in fragment

I have a fragment that has some EditTexts that need to be filled by the user. There's a problem that the soft keyboard hides the EditText so that the user cannot see what they're writing. I don't want the user to scroll manually, I want the fragment to adjust so that it fits the keyboard automatically.
IMPORTANT NOTE: I have seen lots of suggestions to add android:windowSoftInputMode="adjustResize"
or android:windowSoftInputMode="adjustPan"in manifest. However, I want this action to be only for a specific fragment and not for all fragments within the activity.
I have tried adding requireActivity().window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
In onCreateView or in onCreate but nothing seems to change.
In my case,
android:windowSoftInputMode="adjustPan" and ScrollView
it's work for Fragment in Activity.

Closing keyboard leaves white portion in Fragment which are in ViewPager

I am using fragments in my application which are in Viewpager. There is Scrollview in all of the fragments containing many views. When user click on Edittext, keyboard opens but when user click done button on keyboard then keyboard get hidden leaving black screen. I tried a lot my self but no luck. Please guide me..
Have tried almost all the possibilities of configChanges and windowSoftInputMode in manifest file of my activity like,
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:windowSoftInputMode="stateHidden|adjustPan"
And if i load that fragment without viewpager than its working perfectly fine. The issue is with viewpager and fragments with scroll.With keyboard

Open keyboard hides the toolbar below fragment

I have a fragment that is put in an activity. This fragment consists of a VideoViewand EditTextcomponent.
I dont have a problem showing the video or edit the text. The problem occurs when i try to edit the text. When the text is edited and i close the keyboard. The panning have removed my toolbar.
Or atleast put it behind the fragment from some reason
Anyone know why this is happening? Never seen this problem before
Add android:windowSoftInputMode="adjustResize" in your manifest for your 'activity' element

Keyboard windowSoftInputMode fragment

I have a form accidents.
How I can scroll to bottom, when I use keyboard ?
Normally when I use activity I put android:windowSoftInputMode="adjustResize".
But now I'm using fragments, and I can't define in my manifest, searching for internet I found :
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
But it's not Working.
Related posts:
android making layout scrollable when soft keyboard open, but not shifting it upwards
Page scroll when soft keyboard poped up
try by putting this:
android:windowSoftInputMode="adjustResize"
in manifest's activity code in which you are creating fragment.
All fragments of one Activity have the same behaviour as their parent Activity, but if you need different keyboard behaviour for different Fragments, you could dynamically change this property from your Fragment code like this:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.softInputMode.SOFT_INPUT_ADJUST_PAN);
Have a look to this library :
and do something like that :
#Override
public void onKeyboardShown(int keyboardSize) {
Log.d("KEYBOARD", String.valueOf(keyboardSize));
scrollView.scrollTo(0,keyboardSize);
}

Preventing the Android soft keyboard from moving the view up in a Fragment?

I have an activity with four tabs and every tab is implemented as a fragment. In one of these tabs I would like to prevent the soft keyboard from pushing up the view, while the keyboard should still push the views up in the other fragments. Does anybody know how to achieve this?
I cannot use the activity's windowSoftInputMode flag, because that would prevent it for the whole activity with all four fragments.
Try to change flag dynamically
Use the following to change the softInputMode for an Activity in your tab click listener.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);

Categories

Resources