本文整理汇总了Java中android.graphics.drawable.RippleDrawable.getDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java RippleDrawable.getDrawable方法的具体用法?Java RippleDrawable.getDrawable怎么用?Java RippleDrawable.getDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.RippleDrawable
的用法示例。
在下文中一共展示了RippleDrawable.getDrawable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRippleShapeDrawable
import android.graphics.drawable.RippleDrawable; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static GradientDrawable getRippleShapeDrawable(Drawable background) {
if (!(background instanceof RippleDrawable))
return null;
RippleDrawable ripple = (RippleDrawable)background;
Drawable possibleInset = ripple.getDrawable(0);
if (!(possibleInset instanceof InsetDrawable))
return null;
InsetDrawable inset = (InsetDrawable)possibleInset;
Drawable possibleGradient = inset.getDrawable();
if (!(possibleGradient instanceof GradientDrawable))
return null;
// Mutate the drawable, otherwise the color will be set for all instances
possibleGradient = possibleGradient.mutate();
return (GradientDrawable)possibleGradient;
}
示例2: colorButton
import android.graphics.drawable.RippleDrawable; //导入方法依赖的package包/类
@Override
public void colorButton(int id, int bgColor, int tintColor) {
View buttonView = findViewById(id);
RippleDrawable ripple = (RippleDrawable) buttonView.getBackground();
GradientDrawable rippleBackground = (GradientDrawable) ripple.getDrawable(0);
rippleBackground.setColor(bgColor);
ripple.setColor(ColorStateList.valueOf(tintColor));
}
示例3: colorRipple
import android.graphics.drawable.RippleDrawable; //导入方法依赖的package包/类
private void colorRipple(int id, int bgColor, int tintColor) {
View buttonView = findViewById(id);
RippleDrawable ripple = (RippleDrawable) buttonView.getBackground();
GradientDrawable rippleBackground = (GradientDrawable) ripple.getDrawable(0);
rippleBackground.setColor(bgColor);
ripple.setColor(ColorStateList.valueOf(tintColor));
}