zoukankan      html  css  js  c++  java
  • View 属性

    关于 View 设置属性的方式:
    Java
    xml
    style
    defStyleAttr
    defStyleRes
    Theme


    关于 defStyleRes 的使用,和在 xml 中声明 style=”@style/*“ 使用是一样的;
    Theme 中定义,就是在当前应用使用的 theme 中,方式和 style 中定义的一样,其作用范围是全局的,只要有使用这个属性的地方,value 就是 theme 中定义的;
    defStyleRes, defStyleAttr 的作用主要是用于自定义 View 中,想要使用该自定义 View 的地方都是这些属性


    defStyleAttr 使用方法一般如下:
    attr.xml

    1
    <attr name="ZTV_def_style" format="reference"/>

    style.xml

    大专栏  View 属性 class="highlight plain">
    1
    2
    3
    4
    <style name="AppTheme" parent="Theme.AppCompat.DayNight">
    <!-- Customize your theme here. -->
    <item name="ZTV_def_style">@style/---</item>
    </style>

    然后定义你想要指定属性的 style, 再在自定义的 View 中使用 R.attr.ZTV_def_style


    这几中方式的优先级:Java > xml > style > defStyleAttr > defStyleRes > Theme
    原因可以根据使用的习惯想要,defStyleAttr > defStyleRes 在官方文档中有声明 defStyleRes used only if defStyleAttr is 0 or can not be found in the theme。

  • 相关阅读:
    2020春Contest
    HDU Count the string (KMP)
    P1757 通天之分组背包
    L1-050 倒数第N个字符串
    3月份目标
    Division UVa725
    数三角
    luogu P2051 [AHOI2009]中国象棋 dp 状态压缩+容斥
    Codeforces Round #654 (Div. 2) E
    Codeforces Round #654 (Div. 2) D
  • 原文地址:https://www.cnblogs.com/lijianming180/p/12099819.html
Copyright © 2011-2022 走看看