我有调用自定义组件CircleView
,我想改变的自定义属性,叫做fillColor
定义attrs.xml
:
<declare-styleable name="CircleView">
<attr name="radius" format="integer" />
<attr name="fillColor" format="color" />
</declare-styleable>
Run Code Online (Sandbox Code Playgroud)
我最初在我的布局XML中设置了它,它目前看起来像这样(命名空间circleview
定义为xmlns:circleview="http://schemas.android.com/apk/res-auto"
;当我在XML中定义它时,它工作正常,所以这应该不是问题):
<com.mz496.toolkit.CircleView
...
circleview:fillColor="#33ffffff"/>
Run Code Online (Sandbox Code Playgroud)
我能得到的fillColor
属性只是在我的罚款CircleView
,它扩展了View
,但我不知道如何设置它的值.
我已经调查了类似的东西,setBackgroundColor
并寻找其他"设置"方法,但我找不到任何.我想象了一种类似的方法
circle.setAttribute(R.styleable.CircleView_fillColor, "#33ff0000")