lundi 4 janvier 2016

How to apply style to checkbox from code

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?




Aucun commentaire:

Enregistrer un commentaire