private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        if (attrs == null)
            return;

        final Context context = getContext();
        final Resources resource = getResources();
        final float density = resource.getDisplayMetrics().density;

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

        ColorStateList bgColor = a.getColorStateList(R.styleable.FloatActionButton_gBackgroundColor);
        int touchColor = a.getColor(R.styleable.FloatActionButton_gTouchColor, Ui.TOUCH_PRESS_COLOR);
        boolean enabled = a.getBoolean(R.styleable.FloatActionButton_android_enabled, true);
        int shadowColor = a.getInt(R.styleable.FloatActionButton_shadowColor, 0xFF000000);
        float shadowDx = a.getDimension(R.styleable.FloatActionButton_shadowDx, density * Ui.X_OFFSET);
        float shadowDy = a.getDimension(R.styleable.FloatActionButton_shadowDy, density * Ui.Y_OFFSET);
        float shadowR = a.getDimension(R.styleable.FloatActionButton_shadowRadius, (density * Ui.SHADOW_RADIUS));
        int shadowAlpha = a.getInt(R.styleable.FloatActionButton_shadowAlpha, 0x20);
        float touchDurationRate = a.getFloat(R.styleable.FloatActionButton_gTouchDurationRate, 1.0f);
        // Load intercept event type, the default is intercept click event
        int interceptEvent = a.getInt(R.styleable.FloatActionButton_gInterceptEvent, 0x0001);
        a.recycle();

        // Enabled
        setEnabled(enabled);

        // BackgroundColor
        if (bgColor == null) {
            bgColor = UiCompat.getColorStateList(resource, R.color.g_default_float_action_bg);
        }

        // Background drawable
        final float maxShadowOffset = Math.max(shadowDx, shadowDy);

        mShadowRadius = (int) (shadowR + 0.5);
        mShadowRadius += maxShadowOffset;

        ShapeDrawable background = new ShapeDrawable(new OvalShadowShape(mShadowRadius,
                Ui.changeColorAlpha(shadowColor, 0x70)));

        // Background paint
        Paint paint = background.getPaint();

        if (!isInEditMode()) {
            paint.setShadowLayer(mShadowRadius - maxShadowOffset, shadowDx, shadowDy,
                    Ui.changeColorAlpha(shadowColor, shadowAlpha));
        }

        // The background initial before setBackgroundColor
        UiCompat.setBackground(this, background);

        // Set the background color
        setBackgroundColor(bgColor);

        // TouchDrawable
        mTouchDrawable = new TouchEffectDrawable(new FloatEffect(), ColorStateList.valueOf(touchColor));
        mTouchDrawable.setCallback(this);
        mTouchDrawable.setInterceptEvent(interceptEvent);
        mTouchDrawable.setEnterDuration(touchDurationRate);
        mTouchDrawable.setExitDuration(touchDurationRate);

        // We want set this LayerType type on Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
        setLayerType(LAYER_TYPE_SOFTWARE, paint);

        final int padding = mShadowRadius;
        // set padding so the inner image sits correctly within the shadow.
        setPadding(Math.max(padding, getPaddingLeft()),
                Math.max(padding, getPaddingTop()),
                Math.max(padding, getPaddingRight()),
                Math.max(padding, getPaddingBottom()));
    }
This is touch effect FloatActionButton
The button extend see{@link ImageView} widget
<p>
<p><strong>XML attributes</strong></p>
<p>
See {@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_gBackgroundColor Attributes},
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_gTouchColor Attributes}
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_android_enabled Attributes}
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_shadowColor Attributes}
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_shadowDx Attributes}
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_shadowDy Attributes}
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_shadowRadius Attributes}
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_shadowAlpha Attributes}
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_gInterceptEvent Attributes}
{@link net.qiujuer.genius.ui.R.styleable#FloatActionButton_gTouchDurationRate Attributes}
caprice/ui/src/main/java/net/qiujuer/genius/ui/widget/FloatActionButton.java