出现这种问题是由于焦点问题,只需要在RecycleView的父布局中加上
android:focusableInTouchMode="true"
立马解决。
android:focusable与android:focusableInTouchMode的区别
android:focusable:针对的是键盘操作,如果设置为true,则键盘上下左右操作时,焦点也会随之移动。
android:focusableInTouchMode:针对的是触摸操作,当设为true时,我们触摸点击时,相应的就会获得焦点。
当android:focusable=“false”,一定会使android:focusableInTouchMode=“false”。
当android:focusableInTouchMode=“false”,不会影响 android:focusable。
当android:focusableInTouchMode=”true”,一定会有 android:focusable=“true”
由上可知:如果我们要获取焦点,只需设置android:foucusableInTouchMode=“true”就行了。