My problem is the following:
I have a Mainactivity class where I have a method, that gets a TextView with the id colorselected.
Mainactivity method:
@Override
public void onColorSelected(int dialogId, @ColorInt int color) {
this.color = color;
findViewById(R.id.colorselected).setBackgroundColor(color);
//om te tonen welke kleur geselecteerd is
}
TextView in my first XML-file:
<TextView
android:id="@+id/colorselected"
android:layout_width="15dp"
android:layout_height="15dp"
android:background="@drawable/colorselecteddrawable"
... />
As you can see my TextView uses a drawable called colorselecteddrawable, the code in that drawable is:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<corners android:radius="50dp"/>
<solid android:color="#000000" />
</shape>
I'm trying to set the background color of the TextView, whenever the onColorSelected-method
gets executed. However, if I use the method as it is now, my TextView isn't round anymore, probably because the TextView-backgroundcolor gets overwritten, without using the drawable anymore.
So my question is: how can i change my Mainactivity method, so that I can change the <solid android:color="..."/>
tag into the new color, whenever the method gets executed?