android softkeyboard to not cover any part of EditText - android

I am using a ScrollView as the parent in my layout file. In my manifest, for the activity, I have android:windowSoftInputMode="adjustPan". But the problem is that although the focus is not covered by the keyboard, part of the EditText is covered. This makes it difficult to move around in the multiline EditText.
As use case
Say I am four lines in, and I want to go back to line 2 to edit a misspelling. When I try to move the cursor, the EditText jumps up and down, making the user experience crappy. So how do I get the entire EditView to appear above the keyboard? And yes, there is room for that.

Try adding this line to your ScrollView: android:isScrollContainer="false"
See also Forcing adjustPan in activity containing ScrollView for reference.

Related

UI elements don't re-position on opening keyboard

I am currently busy learning how to use Firebase and I've built a very simple UI for my experiment. Unfortunately, when I test the app and I want to fill in the EditTexts with the keyboard, the keyboard is appearing over the UI elements. I can't figure out why this is happening. I've tried out ConstraintLayout and RelativeLayout, but the problem is on both layouts.
Before filling in EditText
During filling in EditText
Thanks in advance!
add this line of cdoe which will scroll the layout to above the soft keyboard.
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
or,
write your layout inside a scrollview
add
android:windowSoftInputMode="stateVisible|adjustResize"
to your activity in the manifest file.

Edit text weird behavior

I have an ExpandableListView which contains a RecyclerView of a custom layout. This layout contains some views including my EditText.
My behavior is : When I click in my number EditText, the keyboard appears for about 0.5s, the whole layout is cleared with default values, then the keyboard disappears, a text EditText appears, and finally I loose focus. When I click on it one more time, the keyboard stays, but in text type. Strange thing : the problem seems to be only on devices where the whole layout overflows the screen because on 10" tablet, everything is ok (layout not cleared, and keyboard not disappearing).
According to me, when I get the focus in the EditText, the layout is re-creates , making it to be cleared.
I tried a long time to figure out what was going on, but I didn't find anything. Here is the things I tried, but didn't change anything :
android:descendantFocusability="beforeDescendants" // on all parent of the EditText
focusable="true" // On the EditText
android:windowSoftInputMode="adjustPan" // In the activity in the manifest
making all the ViewHolder attributes final
As the code is very huge for all that amount of things, I don't know what I should post to help. So don't hesitate to ask anything if it can help
Thanks!
EDIT : A Gif showing the issue https://imgur.com/a/BPue4
Try adding this line to your activity on manifest.xml:
android:configChanges="keyboardHidden|screenSize"
Opening keyboard or screen size changes may trigger to re-create your content.

Android moving edit text automitcally

I have three EditText views named edittext_one ,edittext_two and edittext_three. I have put these views in a ScrollView. These EditTexts are clearly visible on the screen until my keyboard is not open. Now, I click on edittext_one, which is at the top, and my keyboard appears. Then, it hides my edittext_two and edittext_three. I want to go edittext_two just little bit up when I am typing in edittext_one so that user can see edittext_two. Same is happen with edittext_three. When user click on edittext_two, edittext_three slightly move up so user can see it.
I have lots of EditText in a scrollView, but I have just explained here three.
Please don't suggest me to use adjust pan and adjust resize because it never solves my problem.
Here is the link I used for iPhone
Sliding UITextFields around to avoid the keyboard but how do I do this in Android?
Try adding a click listener on edittext_one that does this:
int top = edittext_two.getTop();
scrollView.scrollTo(0,top);

Keyboard issues arising on orientation change

In my app I am using various edit text and text view and list view.
Now my problem is my keyboard appears again on orientation change. Ideally when user minimize the keyboard, it should be in minimized state when device is tilted. But it reappears. How do we handle this situation.
My other problem is one of my edit text is some what at the end of screen. When keyboard appears, it hides the edit text. so user is not able to see what he is typing. What is the ideal way to handle this.
thanks.
Solution to all problem is this line android:windowSoftInputMode="stateUnchanged|adjustResize"
"stateUnchanged" will make the state of keyboard same as it was in earlier state. Either hidden or visible.
"adjustResize" will make your edit text visible.
Hope this helps.!!!
Edit
This need to be added in android manifest file.
I had this same problem. To keep the keyboard from re-appearing on rotation when you have TextViews, you must do 2 things-
Make sure the TextView doesn't have the focus. Even after hiding the keyboard, a TextView can still be focused. Try calling
textView.clearFocus()
and you should be able to see the difference in the TextView.
Make sure there is another view before it (like a parent LinearLayout, or even just a LinearLayout with 0 width and 0 height) which has these properties-
android:focusable="true"
android:focusableInTouchMode="true"
Try adding this code in your Activities properties in the manifest
android:windowSoftInputMode="stateHidden|adjustPan"
Like
<activity
android:name=".MyActivity"
android:windowSoftInputMode="stateHidden|adjustPan" >
This should take care of both your problems
For the Second Question :
You can set your layout to ScrollView to avoid hiding of edittext on Keyboard appears.
Put your entire layout in a ScrollView.
I found the following documentation to be helpful in understanding the various flags associated with the soft keyboard:
https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft

How to prevent the soft keyboard from displaying, or at least evict it once it does?

My app has an EditText that, when I click in it to enter text in the Emulator, brings up a soft keyboard. I don't want this confounded thing to begin with, but then, like the visiting loud-mouthed uncle in the plaid pants, doesn't want to go away, and it is blocking the button beneath it. How do I either (a) prorgrammatically prevent the soft keyboard from appearing or at least (b) evict it, albeit manually, when it pops up?
Provided that the user is not supposed to input text, but is able to click the EditText and then add text in some other way, you could change the EditText to a TextView and then apply the following three tags to it in the layout file:
style="#android:style/Widget.EditText"
android:editable="false"
android:focusableInTouchMode="false"
This will make it look like an EditText, but behave like a TextView.
Since you want the user to be able to write stuff in the EditText there are in my opinion two solutions:
Leave it be. To remove the keyboard, all you need is to hit the back button once and every Android user knows this. It's standard behaviour.
Wrap everything but the Button you say dissapears in a ScrollView. The ScrollView will then wrap its content to allow the Button to be shown in between the keyboard and the ScrollView.
Just set android:editable="false" for your EditText
The answer is to set the focus on an other View like a Button, TextView or similar:
// REQUEST FOCUS
viewName.setFocusableInTouchMode(true);
viewName.requestFocus();
I think what you really need is take a look at android:windowSoftInputMode attribute in Manifest.xml Look into this link.
You can specify the screen to pan/ resize to show the buttons that the input method might be blocking. Not allowing the keyboard to show will make the user unable to enter text at all!

Categories

Resources