How to stop activity resizing/pushing up on keyboard open in dialog? - android

I have an activity, which should react on keyboard opening, so in the manifest, it has an attribute
android:windowSoftInputMode="adjustResize"
Also, this activity can start a dialog, which has EditText. When it starts dialog, keyboard is shown, dialog (which is ok) and activity (not ok) are pushed up. It looks ugly and I want disable pushing of the activity up when dialog is visible.
Is there any beautiful way to solve this problem?
Currently I am changing softInputModeat runtime, it works but it's annoying.
Also why the hell scrollview scroll not working with adjustPan?

Try using adjustPan instead of adjustResize.

Solution:
Firstly,
remove android:windowSoftInputMode="adjustResize" do not even change it from runtime.
Secondly, use <NestedScrollView> and add an attribute to it called:
isScrollContainer="true"
Try it and update here if it is exactly how you need.

use this in your activity tag on manifest:
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="stateHidden|adjustPan"

Related

How to avoid keyboard from appearing with starting FilePickerActivity

I have a button in an activity that starts a FilePickerActivity. Everything works as expected except for the soft keyboard that appears right when the activity starts. I've already tried using the following code line but I can't use it INSIDE the FilePickerActivity because I can't modify it: getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
Is there an extra that I can put in the intent or something to tell that FilePickerActivity to NOT open the soft keyboard on start?
Thanks in advance!
Add this line in your activity tag in manifest:
android:windowSoftInputMode="stateAlwaysHidden"
use android:windowSoftInputMode="stateHidden" in manifest activity tag

Prevent background resize AND prevent auto-focus on activity start

After looking up various questions on stack overflow, I have found that many other people had the following problems:
Background gets resized when soft keyboard opens
Soft keyboard opens when activity starts
The solution to both of these lies in the ActivityManifest.xml.
To prevent the background image from being resized when the soft keyboard opens, you can add android:windowSoftInputMode="stateVisible|adjustPan" to the <activity> in the manifest.
To prevent the soft keyboard opening when the activity starts, you can add android:windowSoftInputMode="stateHidden" to the <activity> in the manifest.
The fact that one solution requires stateHidden and the other requires stateVisible means that I cannot use both solutions. I am looking to prevent the soft keyboard from stealing focus on activity start but also prevent the soft keyboard from resizing the background when the user does decide to focus on the EditText.
Is there a viable solution to both of these issues?
The fact that one solution requires stateHidden and the other requires
stateVisible means that I cannot use both solutions.
Yes. But, you can use stateHidden|adjustPan.
Keyboard will not pop up unless user clicks on an EditText. And potential changes to your background will be in terms of positioning; scaling of the background will not occur.
If your EditText is wrapped within a parent container, set android:focusableInTouchMode="true" for that container. Basically, make that container receive the initial focus when the activity starts. Take a look at this link
Is any part of your layout a scrollable container (like ListView)? If so, try setting android:isScrollContainer="false" on that item in your XML layout.
If you have any views which have android:isScrollContainer="true", the layout manager will attempt to resize your layout when the keyboard pops up, regardless of `android:windowSoftInputMode'.
Here's a similar question: What does android:isScrollContainer do?
There are basically two ways to fulfill your requirement.
Just use the below activity tag
android:windowSoftInputMode="adjustPan|stateAlwaysHidden"
Or
Using
android:windowSoftInputMode="stateVisible|adjustPan" to the activity tag in the manifest.
Now with your EditText use following android:focusableInTouchMode="true" with android:focusable="false".

How Can I force my layout to get pushed up by the keyboard?

I have a relativelayout that fills the screen in an activity. And I launch a softkeyboard with code like this:
((InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE)).toggleSoftInput(InputMethodManager.SHOW_IMPLICIT,InputMethodManager.HIDE_NOT_ALWAYS);
It pops up on top of the RelativeLayout, instead of pushing the relativelayout up. Is there any way I can get the keyboard to do this? I tried adding android:windowSoftInputMode="adjustResize" to my activity in the manifest but this did not help.
Did you try this android:windowSoftInputMode="adjustPan" ? Also, it may be because you add a keyboard dynamically. Try and use only edit-text, as it opens the keyboard natively on click

Keyboard not showing on activity start: Android phones

I have an edittext in my activity, and on activity and on create view
I am setting the focus on the activity. while setting focus, I am also
trying to show the keyboard. It works on some devices, but on others it
just doesn't show.
I tried to step through the code and found that the view is not created, when
the show keyboard is called. Maybe that is the reason.
I am not sure what the problem is. Is there a way to make sure, that if a edit text
is in focus, the keyboard shows up on app start.
Thanks,
You can try to show the Soft Keyboard by calling the following line during onCreate:
getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
I hope that helps.
In your AndroidManifest.xml, add this attribute to the <activity> tag for the Activity you want the keyboard shown:
android:windowSoftInputMode="stateVisible"

Keyboard hidden edittext and there isn't scroll ANDROID

I done a form with 5 edittexts but when the keyboard is going to show the last two edittext I can't see.
Only way to switch to the next fields is to use the buttons on the keyboard.
There is any solution to add a scroll without use the buttons?
I tried with sdk 3, resize keyboard and other things like that.
Why not keep the entire layout in a scrollview. And add the attribute to the activity in manifest file
<activity android:windowSoftInputMode="stateVisible|adjustResize">
So when the keyboard is shown, the layout will be scrollable.
http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
Have you tried adding the android:windowSoftInputMode tag to your activity in the manifest? From what you are describing I would think that either adjustResize or adjustPan should work.

Categories

Resources