Changing color in a shape inside a layer-list programmatically

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)

Leave a Comment