I am enabling orientation change in focusChangeListener of an edittext in my app.
It is working fine, but the issue is if the user flips the keyboard to landscape mode keyboard disappears.
It will come up only if user tap on edittext again or change orientation to portrait mode.
I need to display keyboard in landscape mode without touching the edittext.
Please help me.
Generally, its a bad idea to mess with the default IME behavior because there are devices out there with hardware keyboards.
Now, that you have been warned, listen for the orientation change and if the keyboard was visible before the change and there is no hardware keyboard on the device, show the keyboard manually.
Try using android:configChanges="orientation" into your manifest class.
<activity
android:name=".classname"
android:configChanges="keyboardHidden|orientation"
>
if works then accept it.
Related
When device is rotated from portrait to landscape, keyboard keeps popping up. This happens without being any EditText on the screen. I tested with several devices and it happens only on Samsung devices. Is there a way to prevent keyboard pop ups?
You can use the following code in the activity's onCreate method to make sure the keyboard only pops up when a user clicks into an EditText
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Tested.
Are you tried this one in your manifest fileandroid:configChanges="orientation|keyboardHidden"
Add to root element android:focusableInTouchMode="true" attribute.
Using the method shown in this thread - How to check visibility of software keyboard in Android?
I am able to detect keyboard hide when in portrait mode or in landscape mode where the keyboard is not in fullscreen. If keyboard in landscape mode is fullscreen then, the layout changes are not triggered and hence i cannot detect it in the OnGlobalLayoutListener !
Please help me with this? Is there no simple way to detect keyboard hide?
NOTE: I cannot afford to change anything in the manifest file. It should all be done through code dynamically!
Thanks!
I'm having a small user experience issue in my app;
When changing from landscape to portrait (or portrait to landscape) with the Soft Keyboard open, the keyboard hides.
What I want to do is to stop the keyboard hiding on orientation change.
(Edit - I don't want to force the keyboard open, if the keyboard was hidden before the orientation change, I want it to stay hidden - I want to retain the keyboards open/closed state).
I've looked around for an answer and it seems adding stateUnchanged to the windowSoftInputMode options in the manifest for the Activity is the correct way to solve this (as described in the android documentation:
android:windowSoftInputMode="stateUnchanged|adjustResize"
The problem is this seems to have absolutely no effect.
Does anybody know of any caveats to this functionality? Does it perhaps not work if the EditText which is focused is in a Fragment?
Add this to your code and it will work :
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
a while back I converted my app to include landscape mode, from each activity having screenOrientation="portrait" to this:
<activity
android:name="bundle.android.views.MainActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="fullSensor">
I also handle configuration changes just fine in onConfigurationChanged in each activity.
But in hindsight, I only want edge cases with pop out hardware keyboards to get landscape mode. How do I adjust my manifest and code?
do I keep a certain combination android:configChanges ? the onConfigurationChanged class? insight appreciated
One option is to tackle this problem programmatically. What you could do is detect if the user has a hardware keyboard attached, and if so force the orientation into landscape mode. Here are two ways to detect a hardware keyboard:
http://developer.android.com/reference/android/content/res/Configuration.html#keyboard
and
if (getResources().getConfiguration().hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
}
Once you have detected that the user has a hard keyboard you can force landscape mode on the user with:
myActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
How can I always display the virtual keyboard in landscape mode in startup of the activity? and this keyboard doesn't fill the entire screen so I can display some views above the keyboard. The shape should be like when you open the android web browser in landscape mode then go to an input field. The keyboard doesn't fill the entire screen.
editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI); should solve the problem
For which ever activity you want to display the keyboard only in landscape mode.
Try this in your manifest..
<activity android:screenOrientation="landscape" android:configChanges="orientation|keyboard" android:name="sActivity">