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);
}
Related
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.
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?
I have some EditTexts inside the Navigation Drawer , But when the keyword is coming up it cover the EditText.
I tried the following code inside the activity definition of Manifest but the issue not fixed.
android:windowSoftInputMode="adjustResize"
Any suggestin ?
The windowSoftInputMode flag only works for Activities, which is not the case of a Navigation Drawer.
You can try to calculate the keyboard's height to manually move the EditText above it by using a GlobalLayoutListener: see here for a concrete example.
android:windowSoftInputMode is set normally set on an Activity but I set everything up as one Activity that switches to different Fragments to support tabbing and I need different soft input mode for fragments.
My actual problem is that adjustPan causes text views within webviews to get covered by the keyboard and adjustResize was resizing a view that I was using for calculations and I thought setting different soft input mode for each fragment would be a good workaround.
try this each onCreateView of your fragment
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
i hope its works for you and reply
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);