Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent scrolling to focused EditText [duplicate]

Android scrolls to the focused EditText inside a ScrollView when the activity gains focus.

How can I tell Android NOT to do this but instead maintain scroll position?

The situation:

A validation method must scroll to a TextView for the user's attention. It sets focus to an EditText outside the viewable area to avoid user confusion (which happens when Android sets focus on the closest but unrelated EditText after scrolling down).

The user clicks a button and enters data in a second activity via startActivityForResult. onActivityResult renders the result in the same TextView. Now the TextView is no longer visible because Android scrolls to the focused EditText.

like image 254
user250343 Avatar asked Oct 22 '22 14:10

user250343


1 Answers

Try setSelected(false) for the EditText.

like image 73
Bill Mote Avatar answered Nov 01 '22 13:11

Bill Mote