android - 无法从自定义属性android获取值
问题描述
为什么总是默认值?
private fun setupAttributes(attrs: AttributeSet?) {
val typedArray = context.theme.obtainStyledAttributes(attrs, R.styleable.CustomView,
0, 0)
mColor = typedArray.getColor(R.styleable.CustomView_secondHandColor, Color.CYAN)
paint.color = mColor
}
解决方案
推荐阅读
- nginx - nginx 配置和主页未加载错误
- xampp - 将 MacBook 上 IP 地址的 Xampp 更改为 10.10.xx.xx
- function - Laravel 控制器验证请求不存在
- pycharm - 使用networkx在pycharm上显示图表
- r - 基于多个条件使用for循环进行模拟
- r - plot_annotations 通过 R 中的拼凑消失
- twitter-bootstrap - Vuejs 使用引导数据切换停止事件传播
- python - 按给定顺序重新排序列表
- flutter - 如何在 Flutter 中创建动态 Widget
- python - Python,如何提取包含特定字符的行