[英]How to clear the Focus of the First Edittext in TextInputLayout which is automatically focussed and opens keyboard in android?
I have an Activity. 我有一个活动。 And its Layout is as below.
其布局如下。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:background="@drawable/my_profile_background"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/layEdtEmails"
style="@style/edittextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp">
<EditText
android:id="@+id/edtEmail"
style="@style/edittextStyleHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:maxLength="50"
android:maxLines="1"
android:singleLine="true">
</EditText>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:id="@+id/layEdtPasswords"
style="@style/edittextStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp">
<EditText
android:id="@+id/edtPassword"
style="@style/edittextStyleHint"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/prompt_password"
android:inputType="textPassword"
android:maxLength="15" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</LinearLayout>
The problem is that, the First editText
gets Automatically focussed when Activity Starts. 问题是,活动开始时,第一个
editText
会自动聚焦。 I want to clear that focus when activity starts. 我想在活动开始时清除该焦点。 In xml of
editText
I tried to put focusable as false. 在
editText
xml中,我尝试将editText
设置为false。 But it affects my further coding. 但这会影响我的进一步编码。
在EditText的父级布局中添加android:focusable="true
”和android:focusableInTouchMode="true"
元素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.