Bitmap createButtonShadowBitmap() {
int shadowRadius = (int) buttonElevation * 2;
int bitmapRadius = buttonRadius + (shadowRadius / 2);
int bitmapSize = bitmapRadius * 2;
Bitmap shadowBitmap = Bitmap.createBitmap(bitmapSize, bitmapSize, Bitmap.Config.ARGB_8888);
shadowBitmap.eraseColor(0x0);
int colors[] = {
ColorUtils.setAlphaComponent(SHADOW_COLOR, SHADOW_ALPHA),
ColorUtils.setAlphaComponent(SHADOW_COLOR, 0)
};
float stops[] = {
(float) (buttonRadius - (shadowRadius / 2)) / (float) bitmapRadius,
1f
};
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setShader(new RadialGradient(bitmapRadius, bitmapRadius, bitmapRadius, colors, stops, Shader.TileMode.CLAMP));
Canvas canvas = new Canvas(shadowBitmap);
canvas.drawRect(0, 0, bitmapSize, bitmapSize, paint);
return shadowBitmap;
}
FlyoutMenuView.java 文件源码
java
阅读 31
收藏 0
点赞 0
评论 0
项目:FlyoutMenus
作者:
评论列表
文章目录