解決方法:在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