需求如题,直接选中一个文本框并弹出软键盘并不友好。
解决方法:在xml的根容器中添加两个配置即可:将 focusable
和 focusableInTouchMode
都设为 true
即可。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true">
</LinearLayout>