How can I disable all views inside the layout?

后端 未结 23 1301
一个人的身影
一个人的身影 2020-11-28 08:46

For example I have:



        
23条回答
  •  粉色の甜心
    2020-11-28 09:46

    If you're interested in disabling views in a specific ViewGroup then you can use the interesting, perhaps slightly obscure duplicateParentState. A view state is a set of boolean attributes such as pressed, enabled, activated, and others. Just use this on each child you want to sync to parent ViewGroup:

    android:duplicateParentState="true"
    

    Note that it duplicates the entire state and not just the enabled state. This may be what you want! Of course, this approach is best if you're loading layout XML.

提交回复
热议问题