I have setup a circle (shape) in an xml for a drawable right on a toggle button. The circle.xml has an initial color of green but I cannot get it to show on button. When I used image I am able to see the image so I am sure the issue is with the circle or shape. This it he toggle button with the drawable right.
<ToggleButton
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_weight="1"
android:background="@drawable/custom_fixture_buttons"
android:textColor="@drawable/white"
android:textOff="F1"
android:textOn="F1"
android:drawableRight="@drawable/circle"
android:textSize="30sp" />
This is the code for the circle.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/circle"
android:shape="oval"
android:color="#ff00FFFF" >
</shape>
I have a total of 10 toggle buttons with the drawable right and need to change the colors of each of them separatly, here is a method to set each of the color dots. The first generation used a separate image over each button but I need to change code to apply this to the toggle button drawableright. I tried the setCompoundDrawablesWithIntrinsicBounds but get errors.
switch (index) {
case 0: {
Resources res = getResources();
final Drawable drawable = res.getDrawable(R.drawable.circle);
drawable.setColorFilter(Color.rgb(i, j, k), Mode.SRC_ATOP);
// ImageView img = (ImageView) findViewById(R.id.colordot1);
// img.setBackgroundDrawable(drawable);
// Fixture1.setCompoundDrawablesWithIntrinsicBounds(0, 0,img, 0);
break;
}