试试这个:
try {
item.setDrawingCacheEnabled(true);
Bitmap bmp = item.getDrawingCache();
FileOutputStream out = new FileOutputStream(filename);
bmp.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
}
这item
是我要渲染的视图/视图组。
我实际上在屏幕渲染中使用了相同的片段(减去文件写入),它似乎保留了透明度。
关于颜色的注意事项:
可以在 android 中使用十六进制值指定颜色。一个字节(8 位)可用于图案中的每个颜色值ARGB
(共 32 位)。A
代表Alpha
,R
代表Red
,G
代表Green
和B
. Blue
_ 每个组件的值可以介于 (0, 255) 之间。注意:
decimal 0 = hex 0x00
decimal 255 = hex 0xFF
(no transparency) you would use
因此,如果您想要具有不透明“Alpha #FFFFFFFF . For Black
#FF000000 . For Grey
#FF808080 .
80 80 ”的白色,则为is hex value of decimal 128 and gives you half of full intensity white. so
您提供中值灰色。
使用十六进制算术来获取十进制颜色的值。
AFAIK,径向渐变的角度不应该有任何区别。在 GIMP 中尝试所有这些或阅读 GIMP 教程。如果可以的话,最好还是使用 Photoshop(提供 90 天试用版)。