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

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.

中文表格:

beforeDescendants viewgroup会优先其子类控件而获取到焦点
afterDescendants viewgroup只有当其子类控件不需要获取焦点时才获取焦点
blocksDescendants viewgroup会覆盖子类控件而直接获得焦点

示例:

 

1 <FrameLayout
2                 android:id="@android:id/tabcontent"
3                 android:layout_width="match_parent"
4                 android:layout_height="match_parent"
5                 android:layout_above="@android:id/tabs"
6                 android:descendantFocusability="blocksDescendants"
7                 >
8 ...

 

posted @ 2016-01-29 22:16  f9q  阅读(301)  评论(0编辑  收藏  举报