解决方法:在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>
————————————————
版权声明:本文为CSDN博主「violet-jack」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/violetjack0808/article/details/78599738