Edittext selected at start Activity

Asked

Viewed 535 times

0

I have an Edittext and always when starting the APP it is "selected" it disturbs me a little (with the pointer) how to solve it ? e

1 answer

1


Create a Linearlayout "invisible" above Editext. Then the focus will go 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.