前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >安卓自定义View

安卓自定义View

作者头像
先知先觉
发布2019-01-21 11:25:41
3860
发布2019-01-21 11:25:41
举报

attrs.xml 详解

我们在使用组件属性的时候经常会使用

代码语言:javascript
复制
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="减少分数" 

这些都是系统属性,我们通过attrs.xml可以自己定义属性

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<resources>
    //自定义属性名,定义公共属性
    //name=“样式属性名称” format="样式类型如:String、int、color等"
    <attr name="titleSize" format="dimension"></attr>
    <attr name="titleText" format="string"></attr>
    <attr name="titleColor" format="color"></attr>
    <attr name="outCircleColor" format="color"></attr>
    <attr name="inCircleColor" format="color"></attr>
    <attr name="lineColor" format="color"></attr>

    //自定义控件的主题样式
    //MySportView样式名称
    <declare-styleable name="MySportView">
        <attr name="titleSize"></attr>
        <attr name="titleText"></attr>
        <attr name="titleColor"></attr>
        <attr name="outCircleColor"></attr>
        <attr name="inCircleColor"></attr>
    </declare-styleable>

    <declare-styleable name="MyQQHealthView">
        <attr name="titleColor"></attr>
        <attr name="lineColor"></attr>
    </declare-styleable>
</resources>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016年07月25日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • attrs.xml 详解
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档