Remove auto-Focus from Edit_text when placing windowSoftInputMode="adjustResize"

Asked

Viewed 58 times

1

I’m putting in mine manifest the attribute windowSoftInputMode="adjustResize" so that the edittext is above the keyboard when it is active. The problem is that by doing so, auto-Focus is activated in the edittext as soon as the activity is started. How can I remove this behavior ?

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    android:id="@+id/frame_layout"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/textView_hora"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="20dp"
        android:textSize="18sp"
        android:text="dada" />

    <EditText
        android:id="@+id/editText_hora"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/oval"
        android:padding="8dp"
        android:layout_margin="8dp"
        android:ems="4"
        android:inputType="number" />

    <TextView
        android:id="@+id/textView3"
        android:layout_gravity="center"
        android:textSize="18sp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="dada" />

    <EditText
        android:id="@+id/texto_notification"
        android:padding="14dp"
        android:gravity="start"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_margin="8dp"
        android:layout_weight="1"
        android:background="@drawable/oval"
        android:inputType="textMultiLine" />
    <Button
        android:id="@+id/button"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:text="Cadastrar" />
</LinearLayout>

1 answer

2


Include the flag stateHidden in assigning the windowSoftInputMode:

<application ... >
    <activity
        android:windowSoftInputMode="adjustResize | stateHidden" ... >
        ...
    </activity>
    ...
</application>
  • 1

    Oops, thank you very much, it worked here ! vlw vlw.

Browser other questions tagged

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