本文整理汇总了Java中android.graphics.drawable.RippleDrawable.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java RippleDrawable.setBounds方法的具体用法?Java RippleDrawable.setBounds怎么用?Java RippleDrawable.setBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.RippleDrawable
的用法示例。
在下文中一共展示了RippleDrawable.setBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateRippleDrawable
import android.graphics.drawable.RippleDrawable; //导入方法依赖的package包/类
@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;
}
示例2: generateRippleDrawable
import android.graphics.drawable.RippleDrawable; //导入方法依赖的package包/类
@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;
}