类android.graphics.drawable.RippleDrawable源码实例Demo

下面列出了怎么用android.graphics.drawable.RippleDrawable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Slice   文件: Slice.java
@SuppressWarnings("WeakerAccess")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Slice setRipple(@ColorInt final int mask) {
    if (SDK_LOLLIPOP) {
        if (mask != 0) {
            ShapeDrawable shape = new ShapeDrawable(new Shape() {
                @Override
                public void draw(Canvas canvas, Paint paint) {
                    paint.setColor(mask);
                    canvas.drawPath(((CustomRoundRectDrawable) drawable).buildConvexPath(), paint);
                }
            });

            RippleDrawable ripple = new RippleDrawable(buildColorStateList(mask), drawable, shape);
            view.setBackground(ripple);
        } else {
            view.setBackground(drawable);
        }
    } else {
        Log.i(TAG, "setRipple() only work for API 21+");
    }

    return this;
}
 
源代码2 项目: BackgroundLibrary   文件: DrawableCreator.java
public Drawable build() {
    GradientDrawable drawable = null;
    StateListDrawable stateListDrawable = null;
    if (hasSelectDrawable) {
        stateListDrawable = getStateListDrawable();
    } else {
        drawable = getGradientDrawable();
    }
    if (rippleEnable && rippleColor != null) {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Drawable contentDrawable = (stateListDrawable == null ? drawable : stateListDrawable);
            return new RippleDrawable(ColorStateList.valueOf(rippleColor), contentDrawable, contentDrawable);
        } else {
            StateListDrawable resultDrawable = new StateListDrawable();
            GradientDrawable unPressDrawable = getGradientDrawable();
            unPressDrawable.setColor(rippleColor);
            resultDrawable.addState(new int[]{-android.R.attr.state_pressed}, drawable);
            resultDrawable.addState(new int[]{android.R.attr.state_pressed}, unPressDrawable);
            return resultDrawable;
        }
    }

    return drawable == null ? stateListDrawable : drawable;
}
 
源代码3 项目: BackgroundLibrary   文件: DrawableCreator.java
public Drawable build() {
    GradientDrawable drawable = null;
    StateListDrawable stateListDrawable = null;
    if (hasSelectDrawable) {
        stateListDrawable = getStateListDrawable();
    } else {
        drawable = getGradientDrawable();
    }
    if (rippleEnable && rippleColor != null) {
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Drawable contentDrawable = (stateListDrawable == null ? drawable : stateListDrawable);
            return new RippleDrawable(ColorStateList.valueOf(rippleColor), contentDrawable, contentDrawable);
        } else {
            StateListDrawable resultDrawable = new StateListDrawable();
            GradientDrawable unPressDrawable = getGradientDrawable();
            unPressDrawable.setColor(rippleColor);
            resultDrawable.addState(new int[]{-android.R.attr.state_pressed}, drawable);
            resultDrawable.addState(new int[]{android.R.attr.state_pressed}, unPressDrawable);
            return resultDrawable;
        }
    }

    return drawable == null ? stateListDrawable : drawable;
}
 
源代码4 项目: monthweekmaterialcalendarview   文件: DayView.java
@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;
    }
 
源代码5 项目: FloatingActionButton   文件: Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
    void onActionUp() {
        if (mUsingStyle) {
            mBackgroundDrawable = getBackground();
        }

        if (mBackgroundDrawable instanceof StateListDrawable) {
            StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
            drawable.setState(new int[]{});
        } else if (Util.hasLollipop() && mBackgroundDrawable instanceof RippleDrawable) {
            RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
            ripple.setState(new int[]{});
            ripple.setHotspot(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
            ripple.setVisible(true, true);
        }
//        setPressed(false);
    }
 
源代码6 项目: MusicPlayer   文件: OptionBottomSheet.java
public void addToBeRipple(int drawable,View... v) {
    if(first_time) {
        first_time = false;
        res = getResources();
    }
    int l = v.length;
    rippleViews.addAll(Arrays.asList(v));
    for(View view :v) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            view.setBackground( (RippleDrawable) res.getDrawable(drawable));
        } else {
            //TODO: setBackground below Android L
        }
        view.setClickable(true);
    }
}
 
源代码7 项目: clear-todolist   文件: Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
    if (mUsingStyle) {
        mBackgroundDrawable = getBackground();
    }

    if (mBackgroundDrawable instanceof StateListDrawable) {
        StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
        drawable.setState(new int[]{});
    } else if (Util.hasLollipop() && mBackgroundDrawable instanceof RippleDrawable) {
        RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
        ripple.setState(new int[]{});
        ripple.setHotspot(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
        ripple.setVisible(true, true);
    }
    setPressed(false);
}
 
源代码8 项目: AppPlus   文件: ColorChooseDialog.java
/**
 * 给View设置背景色
 *
 * @param view
 * @param color
 */
private void setBackgroundSelector(View view, int color) {
    Drawable selector = createSelector(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int[][] states = new int[][]{
                new int[]{-android.R.attr.state_pressed},
                new int[]{android.R.attr.state_pressed}
        };
        int[] colors = new int[]{
                shiftColor(color),
                color
        };
        ColorStateList rippleColors = new ColorStateList(states, colors);
        setBackgroundCompat(view, new RippleDrawable(rippleColors, selector, null));
    } else {
        setBackgroundCompat(view, selector);
    }
}
 
源代码9 项目: material-calendarview   文件: DayView.java
@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;
}
 
源代码10 项目: ShareBox   文件: 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
            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;
}
 
源代码11 项目: ShareBox   文件: Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{android.R.attr.state_pressed}, createRectDrawable(mColorPressed));
    drawable.addState(new int[]{}, createRectDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            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;
}
 
源代码12 项目: material-components-android   文件: BaseSlider.java
/**
 * Sets the color of the halo.
 *
 * @see #getHaloTintList()
 * @attr ref com.google.android.material.R.styleable#Slider_haloColor
 */
public void setHaloTintList(@NonNull ColorStateList haloColor) {
  if (haloColor.equals(this.haloColor)) {
    return;
  }

  this.haloColor = haloColor;
  Drawable background = getBackground();
  if (!shouldDrawCompatHalo() && background instanceof RippleDrawable) {
    ((RippleDrawable) background).setColor(haloColor);
    return;
  }

  haloPaint.setColor(getColorForState(haloColor));
  haloPaint.setAlpha(HALO_ALPHA);
  invalidate();
}
 
源代码13 项目: calendarview2   文件: DayView.java
@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;
    }
 
源代码14 项目: talk-android   文件: CircleView.java
@SuppressLint("NewApi")
private void update(@ColorInt int color) {
    innerPaint.setColor(color);
    outerPaint.setColor(shiftColorDown(color));

    Drawable selector = createSelector(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        int[][] states = new int[][]{
                new int[]{android.R.attr.state_pressed}
        };
        int[] colors = new int[]{shiftColorUp(color)};
        ColorStateList rippleColors = new ColorStateList(states, colors);
        setForeground(new RippleDrawable(rippleColors, selector, null));
    } else {
        setForeground(selector);
    }
}
 
源代码15 项目: Slice   文件: Slice.java
@SuppressWarnings("WeakerAccess")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public Slice setRipple(@ColorInt final int mask) {
    if (SDK_LOLLIPOP) {
        if (mask != 0) {
            ShapeDrawable shape = new ShapeDrawable(new Shape() {
                @Override
                public void draw(Canvas canvas, Paint paint) {
                    paint.setColor(mask);
                    canvas.drawPath(((CustomRoundRectDrawable) drawable).buildConvexPath(), paint);
                }
            });

            RippleDrawable ripple = new RippleDrawable(buildColorStateList(mask), drawable, shape);
            view.setBackground(ripple);
        } else {
            view.setBackground(drawable);
        }
    } else {
        Log.i(TAG, "setRipple() only work for API 21+");
    }

    return this;
}
 
源代码16 项目: FloatingActionButton   文件: Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
    StateListDrawable drawable = new StateListDrawable();
    drawable.addState(new int[]{android.R.attr.state_pressed}, createRectDrawable(mColorPressed));
    drawable.addState(new int[]{}, createRectDrawable(mColorNormal));

    if (Util.hasLollipop()) {
        RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][]{{}},
                new int[]{mColorRipple}), drawable, null);
        setOutlineProvider(new ViewOutlineProvider() {
            @Override
            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;
}
 
源代码17 项目: APlayer   文件: CircleView.java
private void update(@ColorInt int color) {
  innerPaint.setColor(color);
  outerPaint.setColor(shiftColorDown(color));

  Drawable selector = createSelector(color);
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    int[][] states = new int[][]{
        new int[]{android.R.attr.state_pressed}
    };
    int[] colors = new int[]{shiftColorUp(color)};
    ColorStateList rippleColors = new ColorStateList(states, colors);
    setForeground(new RippleDrawable(rippleColors, selector, null));
  } else {
    setForeground(selector);
  }
}
 
源代码18 项目: APlayer   文件: Theme.java
/**
 * 按下与选中触摸效果
 */
public static StateListDrawable getPressAndSelectedStateListRippleDrawable(Context context,
    Drawable selectDrawable,
    Drawable defaultDrawable,
    @ColorInt int rippleColor) {
  StateListDrawable stateListDrawable = new StateListDrawable();

  if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
    RippleDrawable rippleDrawable = new RippleDrawable(ColorStateList.valueOf(rippleColor),
        defaultDrawable, null);
    stateListDrawable.addState(new int[]{android.R.attr.state_selected}, selectDrawable);
    stateListDrawable.addState(new int[]{}, rippleDrawable);
    return stateListDrawable;
  } else {
    stateListDrawable.addState(new int[]{android.R.attr.state_selected}, selectDrawable);
    stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, selectDrawable);
    stateListDrawable.addState(new int[]{}, defaultDrawable);
    return stateListDrawable;
  }
}
 
源代码19 项目: BottomSheetPickers   文件: Utils.java
/**
 * Sets the color on the {@code view}'s {@code selectableItemBackground} or the
 * borderless variant, whichever was set as the background.
 * @param view the view that should have its highlight color changed
 */
public static void setColorControlHighlight(@NonNull View view, @ColorInt int color) {
    Drawable selectableItemBackground = view.getBackground();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP
            && selectableItemBackground instanceof RippleDrawable) {
        ((RippleDrawable) selectableItemBackground).setColor(ColorStateList.valueOf(color));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Utils.isTv(view.getContext())) {
            ((RippleDrawable) selectableItemBackground).setRadius(72);
        }
    } else {
        // Draws the color (src) onto the background (dest) *in the same plane*.
        // That means the color is not overlapping (i.e. on a higher z-plane, covering)
        // the background. That would be done with SRC_OVER.
        // The DrawableCompat tinting APIs *could* be a viable alternative, if you
        // call setTintMode(). Previous attempts using those APIs failed without
        // the tint mode. However, those APIs have the overhead of mutating and wrapping
        // the drawable.
        selectableItemBackground.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
    }
}
 
源代码20 项目: Android-3DTouch-PeekView   文件: Peek.java
private void forceRippleAnimation(View view, MotionEvent event) {
    Drawable background = view.getBackground();

    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && background instanceof RippleDrawable) {
        final RippleDrawable rippleDrawable = (RippleDrawable) background;

        rippleDrawable.setState(new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled});
        rippleDrawable.setHotspot(event.getX(), event.getY());

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                rippleDrawable.setState(new int[]{});
            }
        }, 300);
    }
}
 
源代码21 项目: Telegram-FOSS   文件: PagerSlidingTabStrip.java
private void addIconTab(final int position, Drawable drawable, CharSequence contentDescription) {
    ImageView tab = new ImageView(getContext()) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (pager.getAdapter() instanceof IconTabProvider) {
                ((IconTabProvider) pager.getAdapter()).customOnDraw(canvas, position);
            }
        }

        @Override
        public void setSelected(boolean selected) {
            super.setSelected(selected);
            Drawable background = getBackground();
            if (Build.VERSION.SDK_INT >= 21 && background != null) {
                int color = Theme.getColor(selected ? Theme.key_chat_emojiPanelIconSelected : Theme.key_chat_emojiBottomPanelIcon);
                Theme.setSelectorDrawableColor(background, Color.argb(30, Color.red(color), Color.green(color), Color.blue(color)), true);
            }
        }
    };
    tab.setFocusable(true);
    if (Build.VERSION.SDK_INT >= 21) {
        RippleDrawable rippleDrawable = (RippleDrawable) Theme.createSelectorDrawable(Theme.getColor(Theme.key_chat_emojiBottomPanelIcon));
        Theme.setRippleDrawableForceSoftware(rippleDrawable);
        tab.setBackground(rippleDrawable);
    }
    tab.setImageDrawable(drawable);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(v -> {
        if (pager.getAdapter() instanceof IconTabProvider) {
            if (!((IconTabProvider) pager.getAdapter()).canScrollToTab(position)) {
                return;
            }
        }
        pager.setCurrentItem(position, false);
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    tab.setContentDescription(contentDescription);
}
 
源代码22 项目: AcDisplay   文件: RippleDrawable2.java
private Paint getRipplePaint() {
    try {
        Method method = RippleDrawable.class.getDeclaredMethod("getRipplePaint");
        method.setAccessible(true);
        return (Paint) method.invoke(this);
    } catch (NoSuchMethodException
            | InvocationTargetException
            | IllegalAccessException ignored) {
    }
    // Normally should never happen.
    return new Paint();
}
 
@NonNull
private Drawable createForegroundRippleDrawable() {
  if (RippleUtils.USE_FRAMEWORK_RIPPLE) {
    foregroundShapeDrawable = createForegroundShapeDrawable();
    //noinspection NewApi
    return new RippleDrawable(rippleColor, null, foregroundShapeDrawable);
  }

  return createCompatRippleDrawable();
}
 
源代码24 项目: sealrtc-android   文件: SeekBarCompat.java
/**
 * Sets the color of the seekbar ripple
 *
 * @param drawable
 * @param colorStateList The ColorStateList the track ripple will be changed to
 */
public static void setRippleColor(@NonNull Drawable drawable, ColorStateList colorStateList) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ((RippleDrawable) drawable).setColor(colorStateList);
    } else {
        ((AlmostRippleDrawable) drawable).setColor(colorStateList);
    }
}
 
源代码25 项目: SearchPreference   文件: SearchPreferenceResult.java
@TargetApi(21)
protected void forceRippleAnimation(RippleDrawable background) {
    final RippleDrawable rippleDrawable = background;
    Handler handler = new Handler();
    rippleDrawable.setState(new int[]{android.R.attr.state_pressed, android.R.attr.state_enabled});
    handler.postDelayed(() -> rippleDrawable.setState(new int[]{}), 1000);
}
 
源代码26 项目: litho   文件: MatrixDrawable.java
@Override
public boolean shouldHandleTouchEvent(MotionEvent event) {
  return Build.VERSION.SDK_INT >= LOLLIPOP
      && mDrawable != null
      && mDrawable instanceof RippleDrawable
      && event.getActionMasked() == MotionEvent.ACTION_DOWN
      && getBounds().contains((int) event.getX(), (int) event.getY());
}
 
源代码27 项目: Telegram   文件: PagerSlidingTabStrip.java
private void addIconTab(final int position, Drawable drawable, CharSequence contentDescription) {
    ImageView tab = new ImageView(getContext()) {
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);
            if (pager.getAdapter() instanceof IconTabProvider) {
                ((IconTabProvider) pager.getAdapter()).customOnDraw(canvas, position);
            }
        }

        @Override
        public void setSelected(boolean selected) {
            super.setSelected(selected);
            Drawable background = getBackground();
            if (Build.VERSION.SDK_INT >= 21 && background != null) {
                int color = Theme.getColor(selected ? Theme.key_chat_emojiPanelIconSelected : Theme.key_chat_emojiBottomPanelIcon);
                Theme.setSelectorDrawableColor(background, Color.argb(30, Color.red(color), Color.green(color), Color.blue(color)), true);
            }
        }
    };
    tab.setFocusable(true);
    if (Build.VERSION.SDK_INT >= 21) {
        RippleDrawable rippleDrawable = (RippleDrawable) Theme.createSelectorDrawable(Theme.getColor(Theme.key_chat_emojiBottomPanelIcon));
        Theme.setRippleDrawableForceSoftware(rippleDrawable);
        tab.setBackground(rippleDrawable);
    }
    tab.setImageDrawable(drawable);
    tab.setScaleType(ImageView.ScaleType.CENTER);
    tab.setOnClickListener(v -> {
        if (pager.getAdapter() instanceof IconTabProvider) {
            if (!((IconTabProvider) pager.getAdapter()).canScrollToTab(position)) {
                return;
            }
        }
        pager.setCurrentItem(position, false);
    });
    tabsContainer.addView(tab);
    tab.setSelected(position == currentPosition);
    tab.setContentDescription(contentDescription);
}
 
源代码28 项目: LaunchEnr   文件: NotificationMainView.java
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mTextAndBackground = (ViewGroup) findViewById(R.id.text_and_background);
    ColorDrawable colorBackground = (ColorDrawable) mTextAndBackground.getBackground();
    mBackgroundColor = colorBackground.getColor();
    RippleDrawable rippleBackground = new RippleDrawable(ColorStateList.valueOf(
            ThemeUtils.getAttrColor(getContext(), android.R.attr.colorControlHighlight)),
            colorBackground, null);
    mTextAndBackground.setBackground(rippleBackground);
    mTitleView = (TextView) mTextAndBackground.findViewById(R.id.title);
    mTextView = (TextView) mTextAndBackground.findViewById(R.id.text);
}
 
源代码29 项目: discreteSeekBar   文件: SeekBarCompat.java
/**
 * Sets the color of the seekbar ripple
 * @param drawable
 * @param colorStateList The ColorStateList the track ripple will be changed to
 */
public static void setRippleColor(@NonNull Drawable drawable, ColorStateList colorStateList) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ((RippleDrawable) drawable).setColor(colorStateList);
    } else {
        ((AlmostRippleDrawable) drawable).setColor(colorStateList);
    }
}
 
源代码30 项目: MusicPlayer   文件: NowPlayingController.java
@Override
public void onPaletteChanged() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {

        ((RippleDrawable)mPlayPauseButton.getBackground()).setColor(ColorStateList.valueOf(Tool.getBaseColor()));
        ((RippleDrawable)mPrevButton.getBackground()).setColor(ColorStateList.valueOf(Tool.getBaseColor()));
        ((RippleDrawable)mMenuButton.getBackground()).setColor(ColorStateList.valueOf(Tool.getBaseColor()));
        ((RippleDrawable)mNextButton.getBackground()).setColor(ColorStateList.valueOf(Tool.getBaseColor()));
        ((RippleDrawable)mPlaylistTitle.getBackground()).setColor(ColorStateList.valueOf(Tool.getBaseColor()));
    }
    onColorPaletteReady(Tool.ColorOne,Tool.ColorTwo,Tool.AlphaOne,Tool.AlphaTwo);
}
 
 同包方法