I am working on creating a traffic light application. its very simple just a TextView and button. I wanted the TextView to be circular so I created a recourse file in drawable called circular and set it as the label background.
<TextView
android:id="@+id/traffic_light_label"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/circular"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
The label does change from a square a circle shape in the xml file. but when I try changing the background color in the main activity the shape reverts back to square I tried calling the drawable object in the main activity as well but it did not work. any suggestion on what I should do.
Main activity file: this is what causes the shape to revert back to square
light=findViewById(R.id.traffic_light_label);
light.setBackgroundColor(getResources().getColor(R.color.red));
circular recourse file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size android:width="100dp"
android:height="100dp"/>
<solid android:color="#FF0000"/>
</shape>