Remove auto-focus from Edit_text when putting windowSoftInputMode="adjustResize"

1

I'm putting in my manifest attribute windowSoftInputMode="adjustResize" so edittext is above keyboard when it is active. The problem is that by doing this, auto-focus is turned on in edittext once 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>

    
asked by anonymous 22.03.2017 / 22:31

1 answer

2

Include the stateHidden flag in the windowSoftInputMode :

<application ... >
    <activity
        android:windowSoftInputMode="adjustResize | stateHidden" ... >
        ...
    </activity>
    ...
</application>
    
22.03.2017 / 22:41