EditText selected when starting activity

0

I have an EditText and whenever I start the APP it gets "selected" it disturbs me a bit (with the little bridge) how to solve it?

    
asked by anonymous 04.03.2015 / 21:41

1 answer

1

Create a LinearLayout "invisible" above the Editext. Then the focus will come out of your Editext:

<LinearLayout android:focusable="true"
                android:focusableInTouchMode="true" android:layout_width="0px"
                android:layout_height="0px" />

EXAMPLE:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <Button android:text="@string/button_text"; android:id="@+id/Button01"
                android:layout_width="wrap_content" android:layout_height="wrap_content">
        </Button>
        <LinearLayout android:focusable="true"
                android:focusableInTouchMode="true" android:layout_width="0px"
                android:layout_height="0px" />
        <EditText android:text="" android:id="@+id/EditText01"
                android:layout_width="wrap_content" android:layout_height="wrap_content"
                android:hint="@string/hint">
        </EditText>
        <Button android:text="@string/button_text"; android:id="@+id/Button02"
                android:layout_width="wrap_content" android:layout_height="wrap_content">
        </Button>
</LinearLayout>
    
04.03.2015 / 21:45