dimanche 7 mai 2017

Android custom checkbox for set custom font

i created simple widget as custom checkBox as this below code, in this code setting custom font work fine but i can't check or uncheck CheckBox

public class CustomFontCheckBox extends AppCompatCheckBox {

    public CustomFontCheckBox(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
setTypeface(FontManager.getInstance(getContext()).loadFont("fonts/my_font.ttf"));
    }

    public CustomFontCheckBox(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    @SuppressWarnings("unused")
    private void internalInit(Context context, AttributeSet attrs) {

    }
}

xml layout:

<com.myapp.test.Widgets.CustomFontCheckBox
    android:id="@+id/ch1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginRight="@dimen/sickness_depth_marginRight"
    android:button="@null"
    android:buttonTint="@color/colorAccent"
    android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
    android:text="@string/diabetes"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/body_text_color"/>




Aucun commentaire:

Enregistrer un commentaire