Search in sources :

Example 21 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project BoomMenu by Nightonke.

the class BoomMenuButton method setButtonBackground.

private void setButtonBackground() {
    if (backgroundEffect && !inList) {
        if (rippleEffect && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            RippleDrawable rippleDrawable = new RippleDrawable(ColorStateList.valueOf(highlightedColor), Util.getOvalDrawable(button, normalColor), null);
            Util.setDrawable(button, rippleDrawable);
        } else {
            StateListDrawable stateListDrawable = Util.getOvalStateListBitmapDrawable(button, buttonRadius, normalColor, highlightedColor, unableColor);
            Util.setDrawable(button, stateListDrawable);
        }
    } else {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Util.setDrawable(button, Util.getSystemDrawable(context, android.R.attr.selectableItemBackgroundBorderless));
        } else {
            Util.setDrawable(button, Util.getSystemDrawable(context, android.R.attr.selectableItemBackground));
        }
    }
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 22 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project material-calendarview by prolificinteractive.

the class DayView method generateRippleDrawable.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Drawable generateRippleDrawable(final int color, Rect bounds) {
    ColorStateList list = ColorStateList.valueOf(color);
    Drawable mask = generateCircleDrawable(Color.WHITE);
    RippleDrawable rippleDrawable = new RippleDrawable(list, null, mask);
    //        API 21
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
        rippleDrawable.setBounds(bounds);
    }
    //        API 22. Technically harmless to leave on for API 21 and 23, but not worth risking for 23+
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) {
        int center = (bounds.left + bounds.right) / 2;
        rippleDrawable.setHotspotBounds(center, bounds.top, center, bounds.bottom);
    }
    return rippleDrawable;
}
Also used : Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) ColorStateList(android.content.res.ColorStateList) SuppressLint(android.annotation.SuppressLint) RippleDrawable(android.graphics.drawable.RippleDrawable) TargetApi(android.annotation.TargetApi)

Example 23 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project LuaViewSDK by alibaba.

the class ForegroundDelegate method setupForeground.

private static void setupForeground(View view, Drawable drawable, Integer color, Integer alpha) {
    if (view instanceof IForeground) {
        if (color != null) {
            if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
                if (drawable instanceof RippleDrawable) {
                    RippleDrawable rippleDrawable = (RippleDrawable) drawable;
                    rippleDrawable.setColor(ColorStateList.valueOf(color));
                    if (alpha != null) {
                        rippleDrawable.setAlpha(alpha);
                    }
                }
            }
        }
        ((IForeground) view).setForeground(drawable);
    }
}
Also used : RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 24 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project material-camera by afollestad.

the class BaseCameraFragment method setImageRes.

protected void setImageRes(ImageView iv, @DrawableRes int res) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && iv.getBackground() instanceof RippleDrawable) {
        RippleDrawable rd = (RippleDrawable) iv.getBackground();
        rd.setColor(ColorStateList.valueOf(CameraUtil.adjustAlpha(mIconTextColor, 0.3f)));
    }
    Drawable d = AppCompatResources.getDrawable(iv.getContext(), res);
    d = DrawableCompat.wrap(d.mutate());
    DrawableCompat.setTint(d, mIconTextColor);
    iv.setImageDrawable(d);
}
Also used : Drawable(android.graphics.drawable.Drawable) RippleDrawable(android.graphics.drawable.RippleDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 25 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project material-components-android by material-components.

the class FloatingActionButtonLollipop method setBackgroundDrawable.

@Override
void setBackgroundDrawable(ColorStateList backgroundTint, PorterDuff.Mode backgroundTintMode, int rippleColor, int borderWidth) {
    // Now we need to tint the shape background with the tint
    mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(mShapeDrawable, backgroundTint);
    if (backgroundTintMode != null) {
        DrawableCompat.setTintMode(mShapeDrawable, backgroundTintMode);
    }
    final Drawable rippleContent;
    if (borderWidth > 0) {
        mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
        rippleContent = new LayerDrawable(new Drawable[] { mBorderDrawable, mShapeDrawable });
    } else {
        mBorderDrawable = null;
        rippleContent = mShapeDrawable;
    }
    mRippleDrawable = new RippleDrawable(ColorStateList.valueOf(rippleColor), rippleContent, null);
    mContentBackground = mRippleDrawable;
    mShadowViewDelegate.setBackgroundDrawable(mRippleDrawable);
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) InsetDrawable(android.graphics.drawable.InsetDrawable) Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable)

Aggregations

RippleDrawable (android.graphics.drawable.RippleDrawable)34 Drawable (android.graphics.drawable.Drawable)11 Paint (android.graphics.Paint)10 StateListDrawable (android.graphics.drawable.StateListDrawable)10 View (android.view.View)10 ShapeDrawable (android.graphics.drawable.ShapeDrawable)8 TargetApi (android.annotation.TargetApi)7 ColorStateList (android.content.res.ColorStateList)7 GradientDrawable (android.graphics.drawable.GradientDrawable)7 FrameLayout (android.widget.FrameLayout)6 ImageView (android.widget.ImageView)6 ActivityNotFoundException (android.content.ActivityNotFoundException)5 ContentResolver (android.content.ContentResolver)5 Intent (android.content.Intent)5 DisplayMetrics (android.util.DisplayMetrics)5 KeyEvent (android.view.KeyEvent)5 SuppressLint (android.annotation.SuppressLint)4 Outline (android.graphics.Outline)3 ViewOutlineProvider (android.view.ViewOutlineProvider)3 TextView (android.widget.TextView)3