private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        final Context context = getContext();
        final Resources resource = getResources();
        final float density = resource.getDisplayMetrics().density;
        final int baseSize = (int) (density * 2);

        if (attrs == null) {
            mMarkDrawable = new CircleCheckDrawable(resource.getColorStateList(R.color.g_default_check_box));
            setButtonDrawable(mMarkDrawable);
            return;
        }

        // Load attributes
        final TypedArray a = context.obtainStyledAttributes(
                attrs, R.styleable.CheckBox, defStyleAttr, defStyleRes);

        int borderSize = a.getDimensionPixelOffset(R.styleable.CheckBox_gBorderSize, baseSize);
        int intervalSize = a.getDimensionPixelOffset(R.styleable.CheckBox_gIntervalSize, baseSize);
        int markSize = a.getDimensionPixelOffset(R.styleable.CheckBox_gMarkSize, -1);
        ColorStateList color = a.getColorStateList(R.styleable.CheckBox_gMarkColor);
        String fontFile = a.getString(R.styleable.CheckBox_gFont);

        a.recycle();

        if (color == null)
            color = resource.getColorStateList(R.color.g_default_check_box);

        boolean isCustom = true;

        if (markSize < 0) {
            markSize = (int) (density * 22);
            isCustom = false;
        }

        mMarkDrawable = new CircleCheckDrawable(color);
        mMarkDrawable.setBorderSize(borderSize);
        mMarkDrawable.setIntervalSize(intervalSize);
        mMarkDrawable.setMarkSize(markSize, isCustom);
        mMarkDrawable.inEditMode(isInEditMode());
        setButtonDrawable(mMarkDrawable);

        // Check for IDE preview render
        if (!this.isInEditMode()) {
            // Font
            if (fontFile != null && fontFile.length() > 0) {
                Typeface typeface = Ui.getFont(getContext(), fontFile);
                if (typeface != null) setTypeface(typeface);
            }
        }
    }
This is CheckBox widget
The widget extend view widget
<p>
<p><strong>XML attributes</strong></p>
<p>
See {@link net.qiujuer.genius.ui.R.styleable#CheckBox_gBorderSize Attributes},
{@link net.qiujuer.genius.ui.R.styleable#CheckBox_gFont Attributes},
{@link net.qiujuer.genius.ui.R.styleable#CheckBox_gIntervalSize Attributes}
{@link net.qiujuer.genius.ui.R.styleable#CheckBox_gMarkColor Attributes}
{@link net.qiujuer.genius.ui.R.styleable#CheckBox_gMarkSize Attributes}
caprice/ui/src/main/java/net/qiujuer/genius/ui/widget/CheckBox.java