Showing the keyboard without animation - android

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.

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).

Android: Lock components in place with soft keyboard

The soft keyboard moves a TextView object up with it, (adjusting), and this causes the TextView to overlay another TextView that I'd like to be able to see.
I need a way to lock this TextView specifically, so that the keyboard will overlay it. But only that component. I do not want to pan the entire window, just this one, single, TextView object.
Is there a way to tell the TextView, "Dammit bro, don't move with the keyboard" programmatically?
To be honest, I'd also be willing to settle for keeping all of the components from moving, allowing the keyboard to overlay all of them.
Thanks in advance.
So, to answer this, the basic answer is that there is no way to do this.
You can try android:windowSoftInputMode and use "adjustNothing," but apparently this doesn't work (and it didn't work for me either.)
Other than that, you're limited to adjustPan and adjustResize for the soft input repositioning, so you'll have to make your UI accommodate this huge issue.

Android window doesn't resize/pan when softinput opened from WebView

My problem is following.
Application uses theme android:Theme.NoTitleBar.Fullscreen and there is only one Activity, all other views are Fragment
I have WebView inside ViewPager Fragment which is inside ScrollView
HTML content has input fields
I click input field which is on bottom of WebView
Soft input opens, but the Window is not resized/panned
I've tried setting android:windowSoftInputMode="adjustResize" or android:windowSoftInputMode="adjustPan" in my manifest for the Activity. Also tried setting one of those in java.
Normal EditText inside a ScrollView in my application does adjust pan properly so user can see where he/she is typing.
UPDATE:
If there is no working solution to get window adjust, is there a way to get WebView think it's content is like half screen height more bigger so user could at least scroll the input visible.
Okay so this has been an issue from the very beginning and Google hasn't fixed it yet, maybe never. But from the the issue: http://code.google.com/p/android/issues/detail?id=5497 I found potential workaround for this: https://stackoverflow.com/a/19494006/1241783
I have overridden WebView and I simply added the code for it and it is working well enough to get the window adjusted. It is possible though the code doesn't always work because of various screen heights and might need some adjustments, but in many cases it is working okay and I go with that, since it's the only working solution I have seen.
Try this android:isScrollContainer="false" in the ScrollView. According to the Android docx.
Set this if the view will serve as a scrolling container, meaning that
it can be resized to shrink its overall window so that there will be
space for an input method
Hope this will solve your problem
Here is what we have done to make it work.
As it is by design, FLAG_FULLSCREEN activity won't allow adjusting the views when a keyboard is visible, we took an approach with custom Keyboard Notification Listener and OnTouch listener of Webview.
KeyboardHelper.java - to find out the keyboard visibility
Webview Full-Screen Activity Adjustment - To adjust the webview based on the notification and touch point.
Hope it helps!
my code was also not able to resize when keyboard opens.
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/simple_webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none"
/>
i removed (android:scrollbars="none") statement, and it worked ! So that means the app resizes itself only when the container is scrollable. so by default webview containers scrollable area internally.

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.

"adjustResize" 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"

Categories

Resources