declare-styleable的详细用法
来源:互联网 发布:编程打印菱形 编辑:程序博客网 时间:2024/06/16 12:20
1.在resource中定义declare-styleable。
<declare-styleable name="SmileRating"> <attr name="angryColor" format="color" /> <attr name="normalColor" format="color" /> <attr name="drawingColor" format="color" /> <attr name="showLine" format="boolean" /> <attr name="placeHolderSmileColor" format="color" /> <attr name="placeHolderBackgroundColor" format="color" /> <attr name="textSelectionColor" format="color" /> <attr name="textNonSelectionColor" format="color" /></declare-styleable>2.使用:<com.XXX.XXXView>3.在构造方法中获取属性值(注意getColor的key格式)android:id="@+id/ratingView" android:layout_width="match_parent" android:layout_height="wrap_content" app:angryColor="#fff" android:layout_centerVertical="true" />
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.SmileRating);Color1 = a.getColor(R.styleable.SmileRating_angryColor, defValue);Color2 = a.getColor(R.styleable.SmileRating_normalColor, defValue);Color3 = a.getColor(R.styleable.SmileRating_drawingColor, defValue);a.recycle();
阅读全文
1 0
- declare-styleable的详细用法
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- declare-styleable的使用
- TypedArray的用法和declare-styleable:自定义控件的属性
- TypedArray的用法和declare-styleable:自定义控件的属性
- android declare-styleable的使用
- declare-styleable:自定义控件的属性
- php_cookie_session_验证码
- android4.0 MediaPlayer的notify监听机制的全面剖析
- spark streaming 写hdfs问题
- ubuntu下解压缩zip,tar,tar.gz和tar.bz2文件
- 解决eclipse中的项目没有web工程标志的小圆球图标
- declare-styleable的详细用法
- CentOS6.5下RabbitMQ安装
- wicket框架下如何将表格数据导出Excel
- MySQL
- android studio 3.0 使用Kotlin抛弃findViewById()
- android 中uri.parse()各种用法
- 现代化医院PACS/RIS系统概述
- java websocket简单实例绝对可用
- HTML5本地存储详解