I have an activity with many EditText
controls and checkboxes near them. By default, most EditTexts
are disabled.
When I open the activity, some random EditText
control gets focus (a frame around it) and if you tap on it, the on-screen keyboard appears even though the EditText
is disabled and no text appears when you press the on-screen keys.
Also, my whole layout is wrapped in a ScrollView
. When you scroll, some random EditText
s get focus. It can be the lowest visible one, or the highest visible, or sometimes one in the middle, sometimes one outside the visible area.
Because a random element of the layout gets focus, the Activity gets randomly scrolled down when you open it, which is pretty annoying.
I guess it's an Android's bug, but is there a workaround?
Stop EditText from gaining focus at Activity startup handles the situation with only 1 EditText
for which you can tell to lose focus so that the dummy element could gain it. In my case the dummy element doesn't gain focus, both in onResume or onCreate, with both android:focusable="true" android:focusableInTouchMode="true"
Should I check all the EditText controls (there are 12 of them) and tell them to lose focus? What with scrolling, because it seems focus randomly jumps.