情况是这样的:我的一个activity里面有个EditView控件,每次进入到那个界面,就会自动弹出软键盘出来,这样体验感就会很差。应该进去之后不会自动弹出来软键盘,等用户自己点击了EditView再弹出软键盘来。
解决方法:
方法一、在其父控件下,添加如下的属性,就可以完美解决:
android:focusable="true"
android:focusableInTouchMode="true"
例如:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:id="@+id/img_area_pic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:src="@drawable/ic_launcher" />
<EditText
android:id="@+id/et_area_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="@null"
android:hint="房间名"
android:inputType="text"
android:maxLength="6" />
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:text="点击名称或图标可进行修改"
android:textColor="@color/add_title_text_color" />
</LinearLayout>
实测方法一(可能还有其他方法,后续更新)可用,记住是
父布局。