开发过程遇到一个问题,ViewPage明明没有允许获取焦点,但是总是在UI切换的时候能拿到焦点;
设置子控件,父控件,或者ViewPage的属性focusable=“false”,focusableInTouchMode="false"也没用
然后经历各种查阅,发现了一个属性:descendantFocusability,设为blocksDescendants;解决问题.
<androidx.viewpager2.widget.ViewPager2
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"/>
文章讲述了开发者在开发过程中遇到ViewPage在UI切换时意外获取焦点的问题,尽管设置了focusable和focusableInTouchMode为false,但问题仍未解决。最终通过设置descendantFocusability属性为blocksDescendants解决了问题。
866

被折叠的 条评论
为什么被折叠?



