GmRipple.java 文件源码

java
阅读 27 收藏 0 点赞 0 评论 0

项目:GmArchMvvm 作者:
@NonNull
public static Drawable getSelectableDrawableFor(int color) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        StateListDrawable stateListDrawable = new StateListDrawable();
        stateListDrawable.addState(
                new int[]{android.R.attr.state_pressed},
                new ColorDrawable(lightenOrDarken(color, 0.40D))
        );
        stateListDrawable.addState(
                new int[]{android.R.attr.state_focused},
                new ColorDrawable(lightenOrDarken(color, 0.80D))
        );
        stateListDrawable.addState(
                new int[]{},
                new ColorDrawable(color)
        );
        return stateListDrawable;
    } else {
        ColorStateList pressedColor = ColorStateList.valueOf(lightenOrDarken(color, 0.4D));
        ColorDrawable defaultColor = new ColorDrawable(color);
        ShapeDrawable shapeDrawable = (ShapeDrawable) getShapeWithColor(color);
        Drawable rippleColor = getRippleColor(color);
        return new RippleDrawable(
                pressedColor,
                shapeDrawable,
                rippleColor
        );
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号