31

I use TextInputLayout (+ search) in my NavigationDrawer. When user toggle this drawer, the cursor focus appears immediately on TextInputLayout field.

enter image description here

Is it possible not to get focus on this field until user will click on it?

Thanks !

Ardi
  • 1,811
  • 4
  • 17
  • 29

4 Answers4

61

in your root view use this attribute:

        android:focusableInTouchMode="true"
subhash
  • 2,689
  • 18
  • 13
6

None of the answers helped in my case. What I did was the following:

editText.post(() -> {
        textInputLayout.setHintAnimationEnabled(false);
        editText.clearFocus();
        textInputLayout.setHintAnimationEnabled(true);
    });

This is available starting from design support library v23.

azizbekian
  • 60,783
  • 13
  • 169
  • 249
2

Put this in your onCreate():

this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

or add this into your manifest in your activities entry:

android:windowSoftInputMode="stateHidden"
BooleanCheese
  • 615
  • 12
  • 34
0

I fixed this problem , just add another EditText and hide it

        <EditText
          android:layout_width="0dp"
          android:layout_height="0dp" />
        <android.support.design.widget.TextInputLayout
            android:id="@+id/NghiPhep_TextInputLayout_GhiChu"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:hintTextAppearance="@style/TextHintLabel"
            android:layout_marginTop="5dp"
            android:focusableInTouchMode="true"
            >
            <EditText
                android:id="@+id/NghiPhep_txt_GhiChu"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/colorPrimaryDark"
                android:hint="Ghi chú"
                android:fontFamily="@font/arial_rounded"
                android:inputType="textMultiLine"
                android:singleLine="false"
                android:textSize="18sp"/>
        </android.support.design.widget.TextInputLayout>