Android中style内使用自定义属性
来源:互联网 发布:黑泽朋世 知乎 编辑:程序博客网 时间:2024/06/01 10:51
- 0x0001 起因
- 0x0002解决
0x0001 起因
项目要自定义控件,功能相同,但是颜色定制。自带的控件用着都没问题,结果自定义的时候,就碰到了问题。
Error:(2146, 21) No resource found that matches the given name: attr ‘xxxx:ringColor’.
0x0002解决:
自定义文件 /values/attrs.xml
<?xml version="1.0" encoding="utf-8"?><resources> <declare-styleable name="CustomOverlay"> <!--<attr name="customOverlayColor" format="reference|color" />--> </declare-styleable> <declare-styleable name="BorderProgressBar"> <attr name="startAngle" format="integer" /> <attr name="radius" format="dimension" /> <attr name="ringWidth" format="dimension" /> <attr name="centerColor" format="color" /> <attr name="ringColor" format="color" /> <attr name="progressColor" format="color" /> <attr name="textSize" format="dimension" /> <attr name="textColor" format="color" /> <attr name="text" format="string" /> <attr name="isTextDisplay" format="boolean" /> </declare-styleable></resources>
布局中
<com.agfa.android.arziroqrplus.views.BorderProgressBar android:id="@+id/id_round_progressbar" style="@style/ScanUploading" android:layout_width="match_parent" android:layout_height="match_parent" round:isTextDisplay="true" round:radius="60dp" round:ringWidth="8dp" round:startAngle="-90" round:text="@string/string_uploading" round:textColor="@color/white_color" round:textSize="14sp" />
style中
<style name="ScanUploading"> <item name="centerColor">@color/agfa_red</item> <item name="progressColor">@color/cff0d00</item> <item name="ringColor">@color/white_color</item> </style>
用的时候不要加限定
0 0
- Android中style内使用自定义属性
- 如何在android style文件中使用自定义属性
- 如何在android style文件中使用自定义属性
- 如何在android style/layout文件中使用自定义属性。
- 如何在android style文件中使用自定义属性
- 如何在android style文件中使用自定义属性
- 在android style文件中使用自定义属性
- 如何在android style文件中使用自定义属性
- 如何在android style文件中使用自定义属性
- 在android style.xml文件中使用自定义属性
- 如何在android style文件中使用自定义属性
- 在android style文件中使用自定义属性
- android在style中使用自定义属性 error: style attribute not found.
- AndroidStudio中如何在android style文件中使用自定义属性
- android style 中使用自定义的attrs
- Decalre-style Android自定义属性
- android style中出现自定义属性时的写法
- Android:解决style文件不能使用自定义属性
- 数组(时间格式)进行排序
- ACM程序设计 -B 2题 (字典查找)
- 上传文件失败问题 error为7
- 线性表链式存储_api函数实现
- 六大设计原则(下)
- Android中style内使用自定义属性
- 安装oracle 11g时出现启动服务出现错误,找不到OracleMTSRecoveryService
- MySQL索引及查询优化
- 高效使用Bitmaps(三) 神奇的Cache
- Centos更新python以及相应软件及模块的安装
- 利用Spring Interceptor 来缓存指定方法结果
- sed命令详解
- 前端开源项目周报0307
- Spring Boot + JSP(官方不推荐)