Vilius
Vilius

Reputation: 836

Removing focus from multiple EditText in layout on Android

I can remove focus from EditText in layout if it is only one field using this:

android:focusable="true"
android:focusableInTouchMode="true"

But if I add more, it keeps focusing on later one.

Upvotes: 0

Views: 1034

Answers (1)

Michael Yaworski
Michael Yaworski

Reputation: 13483

Take out

<requestFocus/>

from each EditText in your XML.

There is also this and possibly that which helped me.

Summary of the links above:

add these properties to your Relative or Linear Layout:

android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"

So for example:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mainLayout"
    android:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true" >

Upvotes: 1

Related Questions