ViewGroup的下面这个属性可以控制。

原文:

android:descendantFocusability

  Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.

Must be one of the following constant values.

android:descendantFocusability的作用:viewgroup与其上面view的焦点控制,如何让子view失去焦点等。-LMLPHP

中文表格:

beforeDescendantsviewgroup会优先其子类控件而获取到焦点
afterDescendantsviewgroup只有当其子类控件不需要获取焦点时才获取焦点
blocksDescendantsviewgroup会覆盖子类控件而直接获得焦点

示例:

 <FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@android:id/tabs"
android:descendantFocusability="blocksDescendants"
>
...
04-18 12:26
查看更多