本文整理匯總了Java中android.graphics.drawable.RippleDrawable.setHotspotBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java RippleDrawable.setHotspotBounds方法的具體用法?Java RippleDrawable.setHotspotBounds怎麽用?Java RippleDrawable.setHotspotBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.RippleDrawable
的用法示例。
在下文中一共展示了RippleDrawable.setHotspotBounds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}