在您的根视图中使用此属性:
android:focusableInTouchMode="true"
在我的情况下,这些答案都没有帮助我。我做的是:
editText.post(() -> {
textInputLayout.setHintAnimationEnabled(false);
editText.clearFocus();
textInputLayout.setHintAnimationEnabled(true);
});
在onCreate()方法中添加以下代码:
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
android:windowSoftInputMode="stateHidden"
<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>