美文网首页
常用易忘记自定义View相关知识点

常用易忘记自定义View相关知识点

作者: 小智在不在 | 来源:发表于2018-09-13 16:51 被阅读0次

    1.自定义属性定义的位置

    在values文件夹下新建attrs.xml文件,可定义如下结构:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <attr name="titleText" format="string" />
        <attr name="titleTextColor" format="color" />
        <attr name="titleTextSize" format="dimension" />
     
        <declare-styleable name="CustomTitleView">
            <attr name="titleText" />
            <attr name="titleTextColor" />
            <attr name="titleTextSize" />
        </declare-styleable>
    </resources>
    

    其中"format"可选的属性一共是:string,color,demension,integer,enum,reference,float,boolean,fraction,flag 这几种。

    相关文章

      网友评论

          本文标题:常用易忘记自定义View相关知识点

          本文链接:https://www.haomeiwen.com/subject/jgtggftx.html