I have an Android app where layout elements size and margins are defined in dimens files (e.g, values-hdpi/dimens.xml, value-xhdpi/dimens.xml, etc.). That worked fine on a few devices, however on the first device with soft keyboard (htc), my elements are not aligned as it should be (keyboard is moved up and overlap some elements). I should note that I'm using my custom keyboard. How can I overcome this ?
There is no automated way to adjust for the soft keyboard. In fact there is no automated way to even know that the keyboard is up or not. The only response you have to it is the soft input mode, which can either resize your app above the keyboard or pan your app to be above your keyboard.
Related
I have two EditText in my layout, and another layout that contains a custom designed keyboard using ImageButtons. Using these two layouts, I want to:
When the EditText is clicked/touched, hide the default keyboard.
Display the custom keyboard (like a replacement to the default keyboard).
Hide the keyboard after clicking back/return key.
I was able to hide the default keyboard by setting the InputType of the two EditText to NULL. However, it means that the cursor will no longer be visible when EditText is focused. This is part of the specifications of the project.
How do I best approach this problem? What could be a best solution?
Edit: Project specifications were changed. However, I would still love to have the solution or approach to this problem / issue. Thank you very much.
I have an app that uses LOW_PROFILE_MODE to hide soft buttons.
It works quite ok, but when I select a TextView and the software keyboard appears on the screen, the LOW_PROFILE_MODE is gone.
Is there a way to use android soft keyboard and stay in LOW_PROFILE_MODE on Android 5+?
Is it possible to change the size of a keyboard view? The default setting of a keyboard will span across the screen, but is it possible to resize a keyboard? (e.g. make the keyboard only take half of the screen?)
No, not unless you create a custom keyboard and ask users to install it as well.
Why does the soft keyboard change the layout so dramatically when I swap this screen to landscape? It works perfectly fine in portrait. I am assuming that it has to do with the limited space, but the keyboard could still open without covering the EditText that spawned it. It even inserts a Search button. Is there a way to prevent this from happening?
This is default Android behavior, users should be used to it. But if you really don't want this to happen, you can put android:imeOptions="flagNoExtractUi" in the EditText layout.
Also, the "Search" button is what you've specified in the android:imeOptions for the action.
In my application, I am showing/hiding the keyboard to allow the user to manipulate a custom widget. There is no EditText that has focus.
The problem I am having is that I want the layout to adjust in size when the keyboard shows. This is normally done by adding android:windowSoftInputMode="adjustResize" to the activity tag in the manifest. This does work when the device (currently the 7in Galaxy Tab running 2.2) is in portrait mode but when rotated to landscape, the layout does not adjust size and the keyboard hides half the screen.
Now, I noticed that if instead I use an EditView that has android:imeOptions="flagNoExtractUi", the layout resizes appropriately. Is there any way to achieve the same effect on a keyboard displayed through a window token?
Adding a hidden EditView to the screen is not ideal since it will change the implementation rather drastically.
For reference, here is the code I use to show the keyboard within the custom widget.
mInputMethod = (InputMethodManager)getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
mInputMethod.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
requestFocus();
setOnKeyListener(this);
and to hide.
mInputMethod.hideSoftInputFromWindow(getWindowToken(), 0);
setOnKeyListener(null);