When the on-screen keyboard is displayed some UI elements in my layout shrink and/or disappear.
I do not want the underlying UI to change at all when the keyboard displays or hides.
Try try to prevent this I have added keyboardHidden to the configuration changes declaration in my Activity manifest believing that this would tell the system that I will handle any resizing required, but it has made no difference.
Is there a simple way to prevent any resizing when the keyboard displays and is hidden?
It sounds like you want the adjustPan option for the windowSoftInputMode attribute in the manifest:
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.
The details of the different options can be found here
You add it to the activity definition in the manifest like this:
<activity
android:name=".ui.MyActivity"
android:label="#string/my_activity_title"
android:theme="#style/AppTheme"
android:windowSoftInputMode="adjustPan"/>
As above it's worth noting that using this will sometimes push part of your Activity off screen if there is a 'focused' element which would otherwise be hidden by the keyboard.
Related
I have EditText, when i toutch this, keyboard will show, but instead of covering the bottom part of the application, it shifts all the elements at the top and makes them smaller, everything looks distorted ...
How do I display the keyboard so that it does not affect our layout?
Please check this Link:
You can add in your menifest for the activity you want to prevent such issue.
Also make sure if you are having a bit more content use scrollView as a parent.
And soft input mode as "adjustResize"
android:windowSoftInputMode="adjustResize"
or
android:windowSoftInputMode="adjustPan"
you can use as per your need.
adjustResize
to ensure that the system resizes your layout to the available space—which ensures that all of your layout content is accessible (even though it probably requires scrolling)—use this one.
adjustPan
The activity's main window is not resized to make room for the soft keyboard, and 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.
adjustNothing
Do nothing with layouts
I trying to fix layout resize in my Activity when keyboard appear on the screen. I've tried to put in manifest on the activity: windowsSoftInputMode="stateAlwaysHidden" but with not results, my layout is still resizing when I open the keyboard with someone on messenger which is unussual.
If you are doing what I think you are doing, stateAlwaysHidden is not the way to go about it.
<activity android:windowSoftInputMode="adjustPan" >
From the documentation
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, I think what you want. The pan not to change
Here's a link to the documentation regarding it http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
How to make my layout stay on position, when keyboard appears?
Whenever android soft keyboard appears layout view push to up
According to this Android developer guide,
"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.
So add this in your AndroidManifest.xml
<activity android:windowSoftInputMode="adjustPan" > </activity>
You can try setting a Dummy layout below your layout with the width and height of your preference and Set the visibility of the Dummy layout to invisible.
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".
I'm trying to have an AutoCompleteTextView widget in the bottom of my screen, but of course the autocomplete options are not shown because of the keyboard ...
Any tips ? Perhaps it's possible to the the suggestions box opened upwards ?
(used Android's tutorial to check it)
Please add this to your activity in the manifest :
android:windowSoftInputMode="stateHidden|adjustResize"
The activity's main window is always resized to make room for the soft keyboard on screen
or
android:windowSoftInputMode="stateHidden|adjustPan"
he 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
Depending on what suits your needs