Changing color in a shape inside a layer-list programmatically

后端 未结 1 2001
梦谈多话
梦谈多话 2020-12-01 23:55

I am trying to change programmatically the color of the selectable_kachel_shape. Here is the xml file:

kachel_ticked_style.xml

相关标签:
1条回答
  • 2020-12-02 00:05

    Ok I found the answer, I just had to put the id of the shape inside the item not in the shape kachel_ticked_style.xml:

    <item 
        android:id="@+id/selectable_kachel_shape">
            <shape
                 android:shape="rectangle" >
                <stroke
                    android:width="5dp"
                    android:color="@color/headrbar_color" />
            </shape>
        </item>
    

    And then you can change either the color of the shape calling shape.setColor or the color of the stroke calling shape.setStroke(strokeWidth,strokeColor)

    0 讨论(0)
提交回复
热议问题