"adjustResize" Android - android

I have an app that runs fullscreen by using:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Because of this the layout, android:windowSoftInputMode="adjustResize" is not working properly, i.e. it dose not resize.
Is there any way to get over the problem?

FYI: This is an existing AOSP (Android Open Source Project) bug: http://code.google.com/p/android/issues/detail?id=5497
Ideally this bug would be fixed, but until then here are a couple thoughts of how it could be worked around. Since I have no idea what application scenario this pertains to, these may not be very applicable.
In agreement with my best interpretation of the previous answer, design your layout so that adjustPan works ok with it. The first thing I can think of here is not having any headers or footers that are intended to remain on screen when the keyboard is up.
Don't use FLAG_FULLSCREEN with a layout that can accept text input. Possibly it wouldn't be a big deal to show the status bar when accepting input. However, for something that views content with embedded input fields (like a web browser) that has a fullscreen mode, this doesn't make much sense at all.
Implement adjustResize-like behavior of your own. I'm not sure how well this would work, but possibly you could write a subclass of whichever class is causing the keyboard to be shown (ex: EditText) where you either track when the keyboard is shown or take over the calls to show and hide the keyboard (overriding at least onKeyUp and onTouchEvent). When shown, resize your content - possibly with a best guess of the softinput height, since users can install different soft input methods. I believe this would be technically difficult and not reasonable to attempt without extreme need.

Instead of android:windowSoftInputMode="adjustResize" you can try with android:windowSoftInputMode="adjustPan"

Related

How to set on softkeyboard how much to push the content with adjustpan

I would like to use adjustpan in my activity instead of adjustresize, currently the way adjustpan works is if you focus on a keyboard the content pushes upwards, how can set by how much the content is being pushed?
This is how the content looks with adjustpan for example, how can I push it a bit more so the button is not covered by the keyboard without using adjustresize?
You can try out using this:
android:windowSoftInputMode="stateAlwaysHidden|adjustResize"
There isn't any way to do that. The system takes care of it, and there's no input by the app. The only promise is that after the keyboard comes up that the cursor will be visible onscreen.
In practice you probably wouldn't want to do this anyway- different keyboards are different heights, and what you'd want for one won't be right for others.
(You actually probably could do this as the keyboard, since the amount scrolled is controlled by the height of the keyboard, which is determined by the onComputeInsets of the InputMethodService. But its not controlled by the app).

Disappearing soft keyboard in Android app

I have an unusual problem with my Android app. Whenever I focus an input field on a webpage, the soft keyboard appears and immediately disappears.
The app integrates Crosswalk for the browser functionality, though I want to say this used to happen when I used WebView previously.
This is a screen recording of the problem:
It seems to be pushing up or resizing the HTML to accommodate the soft keyboard, but failing for some reason.
Does anyone know why this happens and more importantly, know how to fix it?
EDIT: I've found that if I add android:windowSoftInputMode="adjustPan" to my AndroidManifest.xml file, the problem does not happen. Setting it to "adjustResize" makes it always happen.
Would still love some help if anyone knows the answer :)
The solution to this is a workaround to an Android quirk (of which there are many). From what I've read, this does not happen on iOS, but I have not tested it to confirm.
The problem is when the soft keyboard appears, it triggers a window resize. When you are working with a responsive website, as I am, you are likely to have code that handles resizing. When the keyboard appears, a window resize occurs and the keyboard disappears due to custom resize code.
Solution 1:
The solution is to rewrite resize events to be orientationchange events. While this isn't an ideal situation, if an app is the only target, then it should be fine.
To clarify, change from (using jQuery):
$(window).resize (function ()
{
// Code on resize
});
Change to (using jQuery):
$(window).bind ('orientationchange', function ()
{
// Code on screen rotation
});
I am not sure of the browser support for orientationchange since it's not available on http://caniuse.com, but I can say that it does work with the current version of Crosswalk (19.49.514.4).
Solution 2:
An alternative solution suggested by chrisdew at https://stackoverflow.com/a/9229672/3509051 suggests "adding a listener to the input's focus event which disables reacting to resize events for 0.5s.". This should also work if you are happy to have a 0.5s delay whenever an input is focused.

android:windowSoftInputMode="stateAlwaysHidden|adjustPan" doesnt work on all devices

As many do , I ran into the problem of the softinput covering my send buttons so I did some searching and found the accepted way of fixing this issue is "android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
and this works great on my device, but when I try it on my girlfriends phone it doesnt work. I see the dialog lift a little before the input shows up on screen , but not much and the send button is still covered. Why would this work on some devices , but not all?
Messing with the onscreen keyboard is difficult at best because on the one hand:
It's supposed to be where it is, that way users expect it, it's consistent, very important in UI design
BUT
It can get in the way.
The solution (based on the Android design guidelines, experience and feedback and so forth) is not to faff with it too much, you can have basically the following kinds of behavior:
*Pops up when activity starts (which happens if the activity has an input)
*Doesn't pop up when activity starts (despite the first input having focus <-- good) but will when the user taps.
It's good to dismiss the keyboard when the user is done, that is have the "enter button" take them to the next entry, if there's none left, hide it, if it's some sort of data capture form that validate as they go along, if not don't do this because they might press back in an attempt to get it up.
Addendum I
"adjustResize"
The activity's main window is always resized to make room for the soft keyboard on screen.
"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.
From the documentation here: http://developer.android.com/guide/topics/manifest/activity-element.html
Difference between adjustResize and adjustPan in android?
See there for more.
It's difficult to pan correctly because the layout of the activity can be many things, it could scroll to the left, it could all be relative, it's not one strip where it need only jump up and down, some things also have more than one solution, more than one way to pan so it is visible. You haven't really described what doesn't work btw. I'm trying to explain the issues of what I think you want.
Does this help?
Suddenly got here. You shouldn't mix several values inside android:windowSoftInputMode="" attribute. So, you can preserve android:windowSoftInputMode="adjustPan" and hide a keyboard with hideKeyboard() (look for this method in the Net). Probably you can add listeners to hide it everywhere inside the activity.

Showing the keyboard without animation

I have a problem with the animation of the soft-keyboard since ICS. I got an activity for data entry using the soft-keyboard. The window is set to "adjustResize" in order to fit all Views into the screen above the soft-keyboard.
Since Android 4 the fancy animation of opening the keyboard, let's the views on my screen "bounce".
It seems, as if the view is layouted, then the keyboard opens and after this the screen is relayouted, leading to kind of a jumpy UX.
There was a similar question:
( How to show/hide the soft keyboard without any animation (e.g. fade) in Java? )
However, the solution over there does not work for me. (tested on 4.2.1)
I would be glad, if anyone has some clues on achieving one of the following solutions:
Disable the animation of the soft-keyboard for an activity
Retrieve the size of the soft-keyboard in order to set the size of the screen manually
Cheers,
Florian
You can't get the height of soft-keyboard. I don't think there is a need to do so, you can achieve the same use-case by trying different approach.
If you don't want to re-layout screen, you can use android:windowSoftInputMode attribute in-order to have some more control over the screen rendering when soft-keyboard appears.
For Example : If you don't want to resize the view, you can put the following line in manifest file. This will simply display the keyboard on top of the activity.
<activity android:windowSoftInputMode="adjustPan">
You can check other options for desired functionality.
For better understanding and more controls, you can refer this tutorial.
Hope, this will give you some hint about implementing your use-case.

Any way to "fix" android's assinine keyboard handling?

First of all, I am aware of about 1000 other questions regarding the android keyboard... I am aware I can manually hide keyboard from window or control, and pass in any number of flags that are supposed to control where and when keyboard pops up.
Basically, I aim to have PREDICTABLE keyboard handling in my app... that is that unless explicitly told to focus this control, and popup keyboard, it'll only pop up when a user taps a text edit.
This app is extensive, and manually attempting to hide keyboard from even just the focused control (vs explicitly hiding each and every edit field).
I am also aware I can avoid the popup up keyboard when you dont want it there, by setting focus on a non text editable field, however, that seems like more of a hack than anything else.
So my question is... is there a way to just force app to never auto pop up keyboard on new dialogs, fragments etc... app wide? If I want this text field to et focus on new dialog, I'll manually handle those cases. In addition, any way to automatically handle keyboard dissapear when the previously focused control dissapears?
I just dont get logic there... if I step back and think about this, I'd only want keyboard popping up if I wanted to go type something. As far as keyboard popping up immediately when new dialog opens... seems like the exceptional case (there may be a couple times I'd want to do that).
I dont mind building a manager or something that keeps track of the state of keyboard, however i dont know if I can get at the information I'd need to make it work in a remotely intuitive manner, efficiently.
Any pointers or ideas would be greatly appreciated... because I am at my whits end with this... and I can assure you I've spent a good deal of time researching this and attempting fixes.
Note: Sorry about the title or hostility... I've fought this for quite some time, and been generally infuriated with how bizarre dealing with the keyboard can be.
So my question is... is there a way to just force app to never auto pop up keyboard on new dialogs, fragments etc... app wide?
No.
But you can use:
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
On each activity.
Ok, I think I get what you're asking. Have a look at the second answer here:
Stop EditText from gaining focus at Activity startup
You can specify in your AndroidManifest.xml whether or not the softkeyboard should be hidden by adding this android:windowSoftInputMode="stateHidden" to the beginning of your activities tag (<activity>)

Categories

Resources