概述
Android adjustpan not working after the first time
up vote
19
down vote
favorite
4
|
My problem: starting from the second time the software keyboard is shown on the screen, it entirely hides my EditText. Attribute android:windowSoftInputMode="adjustPan" has been specified in the AndroidManifest.xml, but it works only the first time. I have the following layout:
The "showOrHide" button shows/hides the "addListText"/"addTextListButton" combo. When the EditText is shown for the first time and I touch it, the soft keyboard appears on the screen and the "addListText"/"addTextListButton" combo is panned correctly. When I hide the keyboard and then show it again, the keyboard covers completely my addListText editbox! Any idea on what's going on? I'm testing it on Android 4.2.2. Please help! Thanks :-) edit: I've also tried to put the first LinearLayout inside a ScrollView but it doesn't work!
android
android-layout
android-edittext
android-softkeyboard
| |||
add a comment
| ||||
start a bounty
|
3 Answers
up vote
27
down vote
|
subclassed EditText and overridden the method onKeyPreIme(int keyCode, KeyEvent event) like this:
Now when the back key is pressed, the EditText lost the focus. Then tapping it again adjustpan will work. | ||||||||||||||||||||||||||||||||
add a comment
|
show 2 more comments
|
up vote
38
down vote
|
This may seem a bit silly but I ran into this problem when I set the property gravity of my EditText to either 'center_horizontal' or 'center'. Remove it and you won't run into the problem of the keyboard hiding the EditText the second time (and subsequent ones) when the keyboard comes out. | ||||||||||||||||||||||||||||||||
add a comment
|
show 1 more comment
|
up vote
0
down vote
|
Here is the code I was originally using that ran into this problem:
When I removed the center gravity line from the EditText, the panning worked:
I worked around it by wrapping the EditText in a FrameLayout and centering the entire EditText in the FrameLayout. The one issue it causes is that the EditText will be at least the width of the hinttext, so the first few characters/words typed won't be centered. This was fine for me but your mileage may vary :)
| ||
add a comment
|
最后
以上就是魔幻可乐为你收集整理的Android adjustpan not working after the first time Android adjustpan not working after the first time的全部内容,希望文章能够帮你解决Android adjustpan not working after the first time Android adjustpan not working after the first time所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。