本文整理匯總了Java中android.graphics.drawable.shapes.OvalShape.draw方法的典型用法代碼示例。如果您正苦於以下問題:Java OvalShape.draw方法的具體用法?Java OvalShape.draw怎麽用?Java OvalShape.draw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.shapes.OvalShape
的用法示例。
在下文中一共展示了OvalShape.draw方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLargeNotificationIcon
import android.graphics.drawable.shapes.OvalShape; //導入方法依賴的package包/類
private Bitmap getLargeNotificationIcon(Bitmap bitmap) {
Resources resources = mContext.getResources();
int height = (int) resources.getDimension(android.R.dimen.notification_large_icon_height);
int width = (int) resources.getDimension(android.R.dimen.notification_large_icon_width);
final OvalShape circle = new OvalShape();
circle.resize(width, height);
final Paint paint = new Paint();
paint.setColor(ApiCompatibilityUtils.getColor(resources, R.color.google_blue_grey_500));
final Bitmap result = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(result);
circle.draw(canvas, paint);
float leftOffset = (width - bitmap.getWidth()) / 2f;
float topOffset = (height - bitmap.getHeight()) / 2f;
if (leftOffset >= 0 && topOffset >= 0) {
canvas.drawBitmap(bitmap, leftOffset, topOffset, null);
} else {
// Scale down the icon into the notification icon dimensions
canvas.drawBitmap(bitmap,
new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()),
new Rect(0, 0, width, height),
null);
}
return result;
}
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:26,代碼來源:DownloadNotificationService.java