Code example for ShapeDrawable

Methods: getPaint, setShape

0
    public static final class CheckableLayout extends FrameLayout implements Checkable {
        private boolean mChecked;
 
        private static final ShapeDrawable BG_ON_CHECKED;
        static { 
            final ShapeDrawable drawable = new ShapeDrawable();
            drawable.setShape(new RectShape());
            drawable.getPaint().setColor(0xff5757ff); // 青
            BG_ON_CHECKED = drawable;
        } 
 
        public CheckableLayout(Context context) {
            super(context);
        } 
 
        public void setChecked(boolean checked) {
            mChecked = checked;
            setBackgroundDrawable(checked ? BG_ON_CHECKED : null);
        } 
 
        public boolean isChecked() {