Saad Saad - 6 months ago 38
Android Question

Disable auto focus on edit text

I have an edit text:

<LinearLayout android:id="@+id/linearLayout7" android:layout_width="match_parent" android:layout_height="wrap_content">
<EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:id="@+id/editText1" android:text="3">
<Button android:text="Button" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/button2"></Button>

and then some other stuff underneath

The problem I'm having is that right when the app starts the focus is on the input, i dont want focus to be on input right when the app starts.

I tried removing the


thing and it didn't do anything.


Add the android:focusable="true" and android:focusableInTouchMode="true" elements in the parent layout of EditText as follow;

<LinearLayout xmlns:android=""
    android:id="@+id/linearLayout7" android:layout_width="fill_parent"
    android:focusable="true" android:focusableInTouchMode="true">

I think, it should help you.