Code example for ShapeDrawable

Methods: getPaintsetShape

    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) {
        public void setChecked(boolean checked) {
            mChecked = checked;
            setBackgroundDrawable(checked ? BG_ON_CHECKED : null);
Connect your IDE to all the code out there  Get Codota for Java