I have a strange situation here. In my android app, I have a layout with various edit text and drop down list. My problem is that if I am using virtual keyboard.if for some time I hide the keyboard because I don't want it currently to appear and tilt the device, that is I change from landscape to portrait or vice versa, then again my keyboard appears, although I have minimized it earlier. No matter what i try I had not reached to any solution till now. Since I don't know where exactly my problem is, I am not pasting any code. I can do so if required. Please suggest me something.
My Try: I thought problem is focus on first edit box while tilt so tried
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"
but focus was there and keyboard reappears. So, I am left with even no guess to solve this. So please help!!!
Any help will appreciated. Thanks in advance.
Do I understand you right, it’s just appears when you change orientation?
Why not use the appropriate listener? Like OrientationListener?
Save the status of your keyboard on your activity and read it out on the listener and then set the softkeyboard.
After digging so much I found the solution. in the manifest file I used android:windowSoftInputMode="adjustNothing|stateUnchanged"
This retain the state of keyboard and gives me exactly what I wanted. Apart from that there where few screen where I was getting keyboard like just after login screen, then for that I called hide keyboard method. *Thanks to all for all help. *
Related
I am new in Android. I am creating a calling app, where I am using android keyboard. but at the bottom I want "Dial" Button which should show even after the keyboard is appear. Currently I created a screen where all working is fine but when keyboard appears the "Dial" button is get hidden. This is the scenario, please suggest me, Can we set the location of android keyboard or What else I can do.? Please suggest me how can I do this.
Thanks in advance.
The Wireframe for screen is like below image
I guess this link Might solve your problem.
Android_Dialer
I want to ask how can I make an image/background image not to move when the phone's keyboard is available? Or at least to be cover by the keyboard or something?
In my situation when I call fro the keyboard the image is moved automatically above the keyboard and it doesn't even stay in back ground.
My guess is that value of adjustPan for android:windowSoftInputMode would do the trick for you.
You may also try the other values and see what's best for your case.
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.
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.
I've got an EditText, which is ultimately inside of a ScrollView. I've implemented a comment feature which takes you to a new activity, and automatically places focus in the edit text so that the user can immediately start writing his comment.
Unfortunately, it doesn't quite scroll the edittext into view, as you can see in the screenshot below:
I would like to see something more like this, where the EditText comes completely into view (see below). I already looked at the android:WindowSoftInputMode, and it seems like the default values should work ... and indeed, it does mostly work because it does scroll, just not enough.
So is there anything I can do to get the desired behavior? Thanks!
is your min SDK 3?
check this
Hope you have tried android:windowSoftInputMode="adjustPan" and check this.
I would give this a go.
You could also try to programatically use this on the onCreate() method of you activity.
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
"SOFT_INPUT_ADJUST_PAN" adjustment option is 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.