UI elements don't re-position on opening keyboard - android

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.

Related

Android Scrollview doesn't scroll when keyboard appears onClick of EditText

I've been through n number of solutions for this problem and tried them all but nothing helped.
I have an EditText and onClick of it, a custom keyboard appears but the EditText doesn't comes up above the keyboard.
I have tried putting:
android:windowSoftInputMode="stateAlwaysHidden|adjustPan|adjustResize"
in my Manifest file.
I read somewhere that its a bug and it does not work in FULLSCREEN mode so I removed fullscreen mode from my manifest. Again didn't work.
Please help scrolling my EditText up :D
P.S: Please don't answer for android's default keyboard. I am using my own custom keyboard.
In scrollView use the following code:
in XML:
android:fillViewport="true"
OR
in Java:
setFillViewport(true);
You have to use a translate animation, to move the Edit-text or the entire view above the keyboard along with the Y-axis.
As you are using a custom keyboard,no other way seems to be possible.

android softkeyboard to not cover any part of EditText

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.

how to avoid main window layout being scrolled when soft keyboard is opened?

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.

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

android autocompletetextview hint results hidden under keyboard

I have 3 autocompletetextview's in which i set its adapter to be an ArrayAdapter<String> with a very simple textview layout.
The autocompletextview hint results are showing, but are under the onscreen keyboard(i can see part of it). how can i make the results show above the autocompletetextview rather than below?
airline = (AutoCompleteTextView)findViewById(R.id.airline);
airline.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, AIRLINES_AUTOCOMPLETE_ARRAY));
departLocation = (AutoCompleteTextView)findViewById(R.id.departLocation);
departLocation.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, LOCATIONS_AUTOCOMPLETE_ARRAY));
arriveLocation = (AutoCompleteTextView)findViewById(R.id.arriveLocation);
arriveLocation.setAdapter(new ArrayAdapter<String>(this, R.layout.autcomplete_dropdown, LOCATIONS_AUTOCOMPLETE_ARRAY));
Simply limit the drop-down height.
android:dropDownHeight="200dp"
Then results don't hide by the soft keyboard.
Or else do this
The theory says that android:windowSoftInputMode="adjustPan|adjustResize" should do this but for some reason, it doesn't, so you have to do the same programmatically:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Use a ScrollView for the layout where your Autocomplete resides and Voila!
Does your Activity adjustResize?
android:windowSoftInputMode="adjustPan|adjustResize"
reference: Move layouts up when soft keyboard is shown?
you should look here : Creating an input method
Composing text before committing
If your IME does text prediction or requires multiple steps to compose a glyph or word, you can show the progress in the text field until the user commits the word, and then you can replace the partial composition with the completed text. You may give special treatment to the text by adding a "span" to it when you pass it to InputConnection#setComposingText().
this way, suggestions will apears on soft keyboard prediction like auto-correction. An other way of doing it will be a fullScreen IME... with ExctractEditText : See this link...
This is what i usualy have seen in other apps... i don't think the autocompletetextview can be inverted and appears on top of the view, but what's strange is that it usually shows on top of the keyboard not bellow...
I had the same problem with this a little while ago. You Can try manipulating the z-index of the elements that are being hidden to force it to the top which would be your views in this case. Hope it works for you !
another quick solution is by using the attribute "android:dropDownAnchor"
to anchor the dropdown to some other view on top of screen
Add an attribute in your AndroidManifest.xml
android:windowSoftInputMode="adjustPan|adjustResize"
Which will auto resize and adjust the soft keyboard.
Use
android:windowSoftInputMode="adjustPan|adjustResize"
If none of the above solutions worked. try this
android:dropDownHeight="match_parent"
If we didn't mention the dropdown height, it would be considered wrap_content. Therefore the item will show behind the soft keyboard.
Take the autocomplete textviews in respective layouts then you see they opens their values in it only (ABOVE), set autocomplete texview (bottom) of each layouts, as per your question you required three child layouts.
it is really working

Categories

Resources