ViewGroup屬性小結(jié)

ViewGroup屬性小結(jié):

待改進(jìn)

屬性

  1. android:addStatesFromChildren:Sets whether this ViewGroup's drawable states also include its children's drawable states.[booean]:定義父控件和子控件的狀態(tài)是否關(guān)聯(lián)。(子控件獲取焦點(diǎn)的時(shí)候,整個(gè)布局)

    例子:當(dāng)子控件獲取焦點(diǎn)的時(shí)候讓整個(gè)布局都獲取焦點(diǎn)。

  2. android:alwaysDrawnWithCache :Defines whether the ViewGroup should always draw its children using their drawing cache or not. [boolean] 默認(rèn)為true:定義是否要一直使用緩沖來繪制控件。

  3. android:animateLayoutChanges:Defines whether changes in layout (caused by adding and removing items) should cause a LayoutTransition to run.[boolean]:定義布局改變時(shí)的動(dòng)畫。 設(shè)為true時(shí)會(huì)創(chuàng)建一個(gè)默認(rèn)的LayoutTransition對(duì)象和默認(rèn)的動(dòng)畫。

    方法

    • setLayoutTranstiton(LayoutTransition)
  4. android:animationCache :Defines whether layout animations should create a drawing cache for their children. [boolean]:定義父控件是否要為子控件創(chuàng)建繪制緩存。作用:優(yōu)化性能,但是會(huì)占用更多內(nèi)存

  5. android:clipChildren:Defines whether a child is limited to draw inside of its bounds or not.[boolean]默認(rèn)是true:定義子控件是否要限制在父控件區(qū)域內(nèi)

    方法

    • 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]默認(rèn)true:定義父控件會(huì)不會(huì)限制子控件的大小并且適配邊緣的填充。

    方法

    • setClipToPadding(boolean)
  7. android:descendantFocusability:Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.[enum]:定義父控件和子控件在獲取焦點(diǎn)時(shí)的關(guān)系

    屬性值

    • 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] :定義布局控件在退出的時(shí)候的動(dòng)畫

  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] 默認(rèn)false :布局是否要將動(dòng)作事件分到子控件中。

    方法

    • setMotionEventSplittingEnabled(boolean)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容