ViewGroup属性小结

ViewGroup属性小结:

待改进

属性

  1. android:addStatesFromChildren:Sets whether this ViewGroup's drawable states also include its children's drawable states.[booean]:定义父控件和子控件的状态是否关联。(子控件获取焦点的时候,整个布局)

    例子:当子控件获取焦点的时候让整个布局都获取焦点。

  2. android:alwaysDrawnWithCache :Defines whether the ViewGroup should always draw its children using their drawing cache or not. [boolean] 默认为true:定义是否要一直使用缓冲来绘制控件。

  3. android:animateLayoutChanges:Defines whether changes in layout (caused by adding and removing items) should cause a LayoutTransition to run.[boolean]:定义布局改变时的动画。 设为true时会创建一个默认的LayoutTransition对象和默认的动画。

    方法

    • setLayoutTranstiton(LayoutTransition)
  4. android:animationCache :Defines whether layout animations should create a drawing cache for their children. [boolean]:定义父控件是否要为子控件创建绘制缓存。作用:优化性能,但是会占用更多内存

  5. android:clipChildren:Defines whether a child is limited to draw inside of its bounds or not.[boolean]默认是true:定义子控件是否要限制在父控件区域内

    方法

    • setClipChildren(boolean)
  6. android:clipToPadding:Defines whether the ViewGroup will clip its children and resize (but not clip) any EdgeEffect to its padding, if padding is not zero. [boolean]默认true:定义父控件会不会限制子控件的大小并且适配边缘的填充。

    方法

    • setClipToPadding(boolean)
  7. android:descendantFocusability:Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.[enum]:定义父控件和子控件在获取焦点时的关系

    属性值

    • beforeDescendants:0,The ViewGroup will get focus before any of its descendants.
    • afterDescendants:1,The ViewGroup will get focus only if none of its descendants want it.
    • blocksDescendants:2,The ViewGroup will block its descendants from receiving focus.
  8. android:layoutAnimation: Defines the layout animation to use the first time the ViewGroup is laid out.[reference] :定义布局控件在退出的时候的动画

  9. android:layoutMode:Defines the layout mode of this ViewGroup. [enum]:定义布局的模式:

    属性值

    • clipBounds:0,Use the children's clip bounds when laying out this container.
    • opticalBounds:1,Use the children's optical bounds when laying out this container.

    方法

    • setLayoutMode(int)
  10. android:persistentDrawingCache:Defines the persistence of the drawing cache.[enum]:

    属性值

    • none:0x0,The drawing cache is not persisted after use.
    • animation:0x1,The drawing cache is persisted after a layout animation.
    • scrolling:0x2,The drawing cache is persisted after a scroll.
    • all:0x3,The drawing cache is always persisted.
  11. android:splitMotionEvents:Sets whether this ViewGroup should split MotionEvents to separate child views during touch event dispatch.[boolean] 默认false :布局是否要将动作事件分到子控件中。

    方法

    • setMotionEventSplittingEnabled(boolean)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容