本文整理匯總了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;
}