Example usage for android.graphics.drawable RippleDrawable RippleDrawable

List of usage examples for android.graphics.drawable RippleDrawable RippleDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable RippleDrawable RippleDrawable.

Prototype

public RippleDrawable(@NonNull ColorStateList color, @Nullable Drawable content, @Nullable Drawable mask) 

Source Link

Document

Creates a new ripple drawable with the specified ripple color and optional content and mask drawables.

Usage

From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Drawable createImageViewRippleBg(int colorButtonNormal, int colorControlHighlight) {
    return new RippleDrawable(ColorStateList.valueOf(colorControlHighlight), null,
            createImageViewShape(colorButtonNormal));
}

From source file:arun.com.chromer.util.ColorUtil.java

@NonNull
public static Drawable getRippleDrawableCompat(final @ColorInt int color) {
    if (Utils.isLollipopAbove()) {
        return new RippleDrawable(ColorStateList.valueOf(color), null, null);
    }//w ww  .j  a va 2  s. c  o m
    int translucentColor = ColorUtils.setAlphaComponent(color, 0x44);
    StateListDrawable stateListDrawable = new StateListDrawable();
    int[] states = new int[] { android.R.attr.state_pressed };
    stateListDrawable.addState(states, new ColorDrawable(translucentColor));
    return stateListDrawable;
}

From source file:com.tr4android.support.extension.widget.LabelView.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void initBackgroundLollipop() {
    RoundRectDrawable shapeDrawable = new RoundRectDrawable(mBackgroundColor, mCornerRadius);
    RippleDrawable rippleDrawable = new RippleDrawable(ColorStateList.valueOf(mRippleColor), shapeDrawable,
            null);//from ww  w  .  ja  va2s. c  om

    setElevation(mElevation);
    ViewCompatUtils.setBackground(this, rippleDrawable);
}

From source file:com.appeaser.sublimepickerlibrary.utilities.SUtils.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Drawable createOverflowButtonBgLollipop(int pressedStateColor) {
    return new RippleDrawable(ColorStateList.valueOf(pressedStateColor), null, null);
}

From source file:de.mrapp.android.view.FloatingActionButton.java

/**
 * Adapts the background of the image button, which is used to show the floating image button's
 * background and icon, depending on the floating button's colors.
 *//*from www . j  a  v  a  2s .co m*/
@SuppressLint("NewApi")
private void adaptImageButtonBackground() {
    Drawable background = createStateListBackgroundDrawable();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Drawable rippleDrawable = new RippleDrawable(
                new ColorStateList(new int[][] { {} }, new int[] { getPressedColor() }), background, null);
        ViewUtil.setBackground(imageButton, rippleDrawable);
    } else {
        ViewUtil.setBackground(imageButton, background);
    }
}

From source file:com.winneredge.stockly.wcommons.floatingactionwidget.FloatingActionButton.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[] { -android.R.attr.state_enabled }, createCircleDrawable(mColorDisabled));
    drawable.addState(new int[] { android.R.attr.state_pressed }, createCircleDrawable(mColorPressed));
    drawable.addState(new int[] {}, createCircleDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(
                new ColorStateList(new int[][] { {} }, new int[] { mColorRipple }), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override//from   w w  w . j av a  2  s.c o  m
            public void getOutline(View view, Outline outline) {
                outline.setOval(0, 0, view.getWidth(), view.getHeight());
            }
        });
        setClipToOutline(true);
        mBackgroundDrawable = ripple;
        return ripple;
    }

    mBackgroundDrawable = drawable;
    return drawable;
}

From source file:org.telegram.ui.ActionBar.Theme.java

public static Drawable createBarSelectorDrawable(int color, boolean masked) {
    Drawable drawable;//from  w w w .  j av  a 2  s .c  om
    if (Build.VERSION.SDK_INT >= 21) {
        Drawable maskDrawable = null;
        if (masked) {
            maskPaint.setColor(0xffffffff);
            maskDrawable = new Drawable() {
                @Override
                public void draw(Canvas canvas) {
                    android.graphics.Rect bounds = getBounds();
                    canvas.drawCircle(bounds.centerX(), bounds.centerY(), AndroidUtilities.dp(18), maskPaint);
                }

                @Override
                public void setAlpha(int alpha) {

                }

                @Override
                public void setColorFilter(ColorFilter colorFilter) {

                }

                @Override
                public int getOpacity() {
                    return PixelFormat.UNKNOWN;
                }
            };
        }
        ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] {} }, new int[] { color });
        return new RippleDrawable(colorStateList, null, maskDrawable);
    } else {
        StateListDrawable stateListDrawable = new StateListDrawable();
        stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(color));
        stateListDrawable.addState(new int[] { android.R.attr.state_focused }, new ColorDrawable(color));
        stateListDrawable.addState(new int[] { android.R.attr.state_selected }, new ColorDrawable(color));
        stateListDrawable.addState(new int[] { android.R.attr.state_activated }, new ColorDrawable(color));
        stateListDrawable.addState(new int[] {}, new ColorDrawable(0x00000000));
        return stateListDrawable;
    }
}