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.
Related
When the keyboard appears the RecyclerView doesn't automatically scroll to the position of the selected input field. So the keyboard gets over the selected field.
I tried to add android:windowSoftInputMode="stateVisible|adjustResize" to the activity as suggested in other questions but no luck.
Which layout manager are you using? There is a bug fix about this, but should work in most cases. The bugfix will be released in the next one or after :/, meanwhile, it might work to call scrollToPosition(clickedItemPosition) when keyboard comes up. (TextView focus)
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.
I have a main activity which has RelativeLaoyout # root and many other views including a GridView with 2 columns.
Now, clicking on one of the buttons opens a dialog which has an EditText in it.
When user taps in the EditText the whole RelativeLayout of the main activity is pushed upwards.
I have tried almost all of the solutions I could find on stackoverflow and various other forums but none has worked for me!
Things I have tried so far
Set android:windowSoftInputMode="adjustResize"
I also tried adjustNothing and adjustPan but nothing worked
Set android:isScrollContainer="false" for the GridView
I also tried setting it to true. But that didn't help either.
This issue is really bugging me very bad. Please someone help!
EDIT
Found a duplicate but that too is un-answered!
background layout moving when soft keyboard displayed - android
how adjust pan will work it just push ur edit text not ur whole background if ur edit text is in b/w the height of keyboard that comes up to the screen, the adjust pan just lift the edit text not the whole background screen and if ur edit text is above from the height of keyboard then no change will occur.
Do you have Fullscreen theme?
#android:style/Theme.Holo.NoActionBar.FullScreen
If so, try changing it to:
#android:style/Theme.Holo.NoActionBar
It seems that in HoneyComb version and above the full screen theme setting overrides the windowSoftInputMode adjustResize or adjustPan settings.
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
I am working on an android Application where I am willing to get input from user. I created a layout for it which has a scroll view as a root view & Relative layout as it's child all the other layout are inside this Relative layout. But when edit text is at the bottom of screen & user click on it to bring keyboard it shows some blank box between edit text & keyboard & after this if user enters any word it doesn't get displayed in edit text. But if Edit text is above nearly more then half size of screen it works fine. You can get more clearly by looking at images below
Here is my code
Does anyone faced this kind of problem?? Please help!!!
The default IME mode set on the activity in the manifest (android:windowSoftInputMode="adjustPan") will pan the main layout so the text field is in the middle of the viewable area. While the majority of your content is in a scrollable region, it is simply moving the whole region and not scrolling the contents into view. If you use android:windowSoftInputMode="adjustNothing" it will prevent the layout panning, but will also effectively do nothing and just cover your original input.
MY recommendation would be to use adjustResize, this might fix it for you. If not, you have to look into doing some custom scroll-region focusing.