0

i have check box

                <CheckBox
                    android:id="@+id/chk1"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:textColor="#FFFFFF"
                    android:textColorHint="#FFFFFF"
                    android:textSize="12dp"
                    android:theme="@style/MyCheckboxTheme"/>

From above code i am able to set the android:theme to my checkbox. But i want to set this theme from code side.

I have write this for Checkbox from code side:

    chk1.setTextColor(Color.parseColor("#FFFFFF"));
    chk1.setHintTextColor(Color.parseColor("#FFFFFF"));
    chk1.setTextSize(12);

But how can i apply style to checkbox through code?

1 Answers1

0

Depending on the API level that you are targeting, you need to create a new style, and point your checkbox style to this.

Please refer here, as this shows a detailed explanation of this.

Community
  • 1
  • 1
TejjD
  • 2,571
  • 1
  • 17
  • 37