In my Android application running in a XOOM device, when I click in an Edittext the keyboard opens and hides the Actionbar. I don't want this to happen, how can I solve this? This is done by the Google Contacts app for the tablet for example.
EDIT:
I have several edittexts in which the user needs fo fill. At first, when the user clicked on one edittext on the bottom, the keyboard showed up and hide the edittext in which the user was typing, so he couldn't see what he was typing. I found it really bad, and to solve it I just added to the manifest: android:windowSoftInputMode="stateVisible|adjustPan"
But after that, now the screen adjust itselfs and hides the action bar.
The Google Contacts app does the same, but it magically doesn't hide the Action bar. How do they do it?
Use adjustResize instead of adjustPan. The framework will always try to keep the focused element on-screen by scrolling any parent views if necessary.
If your EditText field is not nested in some sort of scrolling container such as a ScrollView then your layout may be too tall to completely display when the keyboard resizes your activity. Try wrapping your form's layout in a ScrollView. This will also allow your app's content to scroll if it is running on a smaller screen device where it may have similar issues.
Related
I have an activity with BottomNavigation. If the user needs to click on the submit button soft keyboard hides it. Then he again needs to press the back button to see the submit button. In this case, I used windowSoftInputMode='adjustResize' so that the screen gets resized automatically and the user can scroll up and click on the submit button.
But, I have BottomNavigation too, windowSoftInputMode='adjustResize' makes BottomNavigation float above the soft keyboard. Can anyone suggest a better solution? Any help will be appreciated. Thanks
Thats tricky issue... You have two options in here:
Keep 'adjustResize' and hide BottomNavigation view when keyboard pops up (e.g. simply setVisiblity?)
Change to e.g. 'adjustPan' (or any other) preventing keyboard resizing app and add bottom padding with height of keyboard for whole content container. BottomNavigation will stay hidden under keyboard, but padding will allow scrolling to Submit button
In both cases you need to detect open/close keyboard, in second case you will also need keyboard height measuring. IN HERE and HERE you have big SO topics about this case, check out answers and comments, and pick proper resolution for your purposes
I have an EditText element at the bottom of the screen (like Whatsapp i.e), and I'm using android:windowSoftInputMode="adjustPan" in order not to hide the EditText when the keyboard appears. It works fine, it pushes the whole layout up so that the EditText can be seen.
Now, the problem is that when I select the text, the action mode bar doesn't appear, as if it was pushed up along with the layout.
I'm not using an explicit action bar in my layout, it's the one that appears on pre M devices when a text selection is made.
The layout hierarchy goes like this:
<FrameLayout>
<GLSurfaceView/>
<EditText/>
</FrameLayout>
So all I want to do is this action mode to keep it's position even when the keyboard is opened, using the pan behaviour.
adjustResize doesn't work for me. When set, the keyboard is over the EditText, and nothing resizes, probably due to GLSurfaceView.
Thanks!
I have two EditText views and one ImageView. My goal is to hide the ImageView when i am showing the keyboard (When the user have clicked on one of the EditText fields)
Then show the imageView again when the user have unfocused the EditText field or the keyboard is not visible anymore.
I have tried tons of different ways to do this. But nothing really works as intended. Do you guys have any idea how i could achieve this
Have you tried to detect if the keyboard is opened ? How do I Detect if Software Keyboard is Visible on Android Device?
Make debug and when is opened try to hide image . imageview.setvisibility (GONE)
if it does not work you can try to change layout
Make 2 layouts and switch visibility if the keyboard is open /closed
You can add a OnFocusChangeListener to the EditText,when you click the EditText,it will get focus,and then you can hide the ImageView.
<activity android:name="SearchResultsActivity"
android:windowSoftInputMode="adjustPan"/>
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.
regards! :)
You can do one thing, place UIView-> UIImageView -> UITextfield1-> UITextField2.Handle the UIImageView hiding state in textfield delegates which are Begin and End editing delegate methods
I have a TabActivity which has the tabs across the bottom of the screen. My first tab hosts an activity which consists of a fixed header layout at the top of the screen, and a ScrollView beneath it which contains several EditText controls. The ScrollView scrolls it's content fine between the header bar and the bottom tabs, the problem occurs when an EditText is tapped and the soft keyboard appears. I understand to control the behaviour of the views when the keyboard appears I need to use the windowSoftInputMode attribute in the manifest XML file. However I've tried both the following settings :
adjustResize - Gives the correct functionality for the ScrollView and the header layout remains fixed at the top of the screen. However the tab bar controls are pushed up on top of the keyboard.
adjustPan - The tab bar controls remain at the bottom of the screen beneath the keyboard (which is what I want) but the other views are pushed up by the keyboard meaning the header layout gets pushed up off the screen.
It seems I need characteristics of both settings, but they can't be used together. I've heard of the setting adjustNothing but if I try this my project fails to build as it doesn't recognise this setting. I guess I need my tab host activity to have adjustPan but my content activity to have adjustResize but it seems you can't combine the two as it's the tab host activity that takes precedence.
Any help greatly appreciated.
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.
In my android application, I have an EditText. When I click in this field, the soft keyboard appears, expanding from the bottom of the screen. It seems to actually modify my layout, pushing contents upwards. When I dismiss the keypad, it retracts, and I see my layout re-expand to take up the space it previously occupied.
Is there a way to get the keyboard to simply appear "on top" of my layout, so that I don't get this somewhat unpleasant relayout animation? The EditText is pinned to the very top of the screen, so I don't have to worry about the keypad hiding it.
Thanks
By default, Android should be using "Pan and Scan", which would work more or less how you described. The keyboard is displayed over your view, and you can scroll your view in the background. If you override the windowInputMode for you Activity, or Android determines that your Activity is resizable (because of the presence of a resizable field... ListView, ScrollViews, etc), it may resize your view instead, and it sounds like that's what you're running into. To force it to Pan and Scan try adding:
android:windowSoftInputMode="adjustPan"
as an attribute to the Activity element in your xml layout.
There's a third option as well. You can specify that when an EditText is selected it will be edited in full screen mode. The other controls in your view will be hidden, the user will be presented with just the keyboard, an EditText control, and optionally some other limited controls. If your EditText doesn't require a lot of context from other elements of your view, it may prevent a cleaner user interface. For more details, see: http://android-developers.blogspot.com/2009/04/updating-applications-for-on-screen.html
Add:
android:windowSoftInputMode="adjustResize"
to your activity attr in manifest.xml. Hope it will help.
This questions seems to state a resize is not desirable. I had the same issue, but adding
android:windowSoftInputMode="adjustNothing"
to the manifest file instead solved my problem.