在我们平时使用EditText的过程中,我们通常是这样写的:
<EditText
android:id="@+id/note_personal_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginTop="@dimen/dp_8"
android:layout_weight="1"
android:background="@color/white"
android:hint="可通过手机号在发票服务平台查询"
android:inputType="number"
android:maxLength="11"
android:textColor="@color/sheQu_text_bleak"
android:textSize="@dimen/dp_10" />
这样的情况下,也是可以的,但是我们往往会忽略一些细节,就是在EditeText是默认存在焦点的,在使用的时候,它会默认调起键盘,但如果我们在进入页面中,不需要默认调起的话,我们就需要给EditText不设置焦点。
所以,我们需要在书写EditText的时候,给外面加上一个父布局,加上两个属性:
android:focusable="true"
android:focusableInTouchMode="true"
这样就可以解决了。