Android技术开发

防止ScrollView内部的RecyclerView获取焦点把

2019-07-03  本文已影响0人  一点墨汁
image.png

如何放在ScrollView内部的RecyclerView抢焦点呢?
举个例子:
如果ScrollView的孩子节点是LinearLayout,那么我们只需要设置LinearLayout的属性就可以了。

<LinearLayout
......
android:descendantFocusability="blocksDescendants">

</LinearLayout>

android:descendantFocusability属性的值有三种:

beforeDescendants:viewgroup会优先其子类控件而获取到焦点

afterDescendants:viewgroup只有当其子类控件不需要获取焦点时才获取焦点

blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点

搞定!试试吧!

上一篇 下一篇

猜你喜欢

热点阅读