<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="@dimen/radius_default"/>
<solid
android:color="@color/alpha"/>
<stroke
android:width="1dp"
android:color="@color/red"/>
</shape>
I want to change stroke's color at runtime.
I used this code but it didn't work.
Drawable drawable = getResources().getDrawable(R.drawable.border_red);
drawable.setColorFilter(Color.BLUE), PorterDuff.Mode.SRC_ATOP);
container.setBackground(drawable);
How can I change stroke's color?
float[] outerR = new float[] { 12, 12, 12, 12, 0, 0, 0, 0 };
RectF inset = new RectF(6, 6, 6, 6);
float[] innerR = new float[] { 12, 12, 0, 0, 12, 12, 0, 0 };
ShapeDrawable biggerCircle = new ShapeDrawable(new RoundRectShape(outerR,inset, innerR));
biggerCircle.setIntrinsicHeight( 60 );
biggerCircle.setIntrinsicWidth( 60);
biggerCircle.setBounds(new Rect(30, 30, 30, 30));
biggerCircle.getPaint().setColor(Color.BLUE);
border.setBackgroundDrawable(biggerCircle);
i do not refactoring yet, but this code is work for me. thank you