I have a TextView with rounded corners.
Here is my code:
float radius = 10f;
ShapeAppearanceModel shapeAppearanceModel = new ShapeAppearanceModel()
.toBuilder()
.setAllCorners(CornerFamily.ROUNDED,radius)
.build();
MaterialShapeDrawable shapeDrawable = new MaterialShapeDrawable(shapeAppearanceModel);
ViewCompat.setBackground(textView,shapeDrawable);
Now, I want to change programmatically the background color of the textView.
When I do :
shapeDrawable.setFillColor(ContextCompat.getColorStateList(this,R.color.design_default_color_background));
it works; the background color is changed.
Now, I want to change the background color with an int color like Color.RED or any random color defined with Color.RGB(r, g, b, a) or Color.RGB(r, g, b).
How can I do that? Should I use shapeDrawable.setFillColor or another method?
Thanks.