I am trying to solve the issue that in my Webview, when a user selects a textfield, the keyboard that appears covers the text field below.
Instead, I need a behavior where the text field is moved right above the keyboard, like what the flag SOFT_INPUT_ADJUST_PAN would do.
Based on testing, it seems like by default on a Webview, it is displaying the keyboard below the field.
But my WebView is in fullscreen. I am calling this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN) in my activity);
and this seems to make android stop doing the default 'pan and scan' behavior.
I've tried to call
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN)
and even
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
but that did not fix it.
I need to set the activity to fullscreen because I want to hide both the title bar and the status bar, so removing it is not an option unless there is another way to hide the status bar.
Any idea on how to solve this issue?
Laurent
You need to remove FLAG_FULLSCREEN flag. There is a bug somewhere in the OS machinery and with some digging around i have found the following:
without any extra scroll view around web view adjustPan never worked for me. Unfortunatelly the add scroll view also not always helps.
adjustScroll works for me when FLAG_FULLSCREEN is not present for the activity the webview is in.
So to sum it up the safest option to go with when it comes to WebView is adjustResize not full screen activity.
For me this worked:
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Related
I am using Collapsing ToolBar and Tab to make this layout. When the EditText cursor is enabled the entire activity has to be pushed up. Even here I used the same working code which is working good in an another app without Collapsing ToolBar. But here it is missed to work. Please help me.
This is the code that I used in another activity which is working good.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN |
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
From the WindowManager documentation:
SOFT_INPUT_ADJUST_PAN
Adjustment option for softInputMode: set to have a window pan when an input method is shown, so it doesn't need to deal with resizing but just panned by the framework to ensure the current input focus is visible.
Try setting the soft input mode to only WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE and see if that fixes your problem.
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 know this answer has been asked multiple times but there has not been a legit answer that solves this issue. To this day, I cannot believe Google has not added a listener for the SoftKeyBoard. I am curious to know if anyone has a solution to listening to the backPress while the keyboard is visible? I am asking this because within the Google play store when the search is visible and you press back, it hides the search and the keyboard at the same time. I have recreated the search but cannot find a legit answer to closing a custom searchview and the keyboard at the same time. I have tried a lot of answers but none of them are working.
I am calling "adjustPan" within the Manifest MainActivity to prevent custom views from being shifted. "adjustPan" prevents the root layout from making room for the softKeyboard, rather the softKeyboard is above the root layout. So this eliminates any measure solutions, which have been the main solution to most of the answers.
android:windowSoftInputMode="adjustPan"
Here is the custom SearchView
It is likely that Google is not listening for the onBackPressed event - but rather configuration changes that involve the keyboard. If you want to hide something when the keyboard changes to "hidden" then monitor the configuration with onConfigurationChanged and it will have the same effect.
See this post: How to capture the "virtual keyboard show/hide" event in Android?
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.
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.