Java 带循环进度视图的Android Mask ImageView
我正在尝试使用using PorterDuff.Mode.DST_屏蔽imageview,这里是用于屏蔽的示例代码Java 带循环进度视图的Android Mask ImageView,java,android,android-layout,porter-duff,Java,Android,Android Layout,Porter Duff,我正在尝试使用using PorterDuff.Mode.DST_屏蔽imageview,这里是用于屏蔽的示例代码 public static Bitmap getMaskedBitmap(Resources res, int sourceResId,Bitmap mask) { BitmapFactory.Options options = new BitmapFactory.Options(); if (Build.VERSION.SDK_INT >= Build.
public static Bitmap getMaskedBitmap(Resources res, int sourceResId,Bitmap mask) {
BitmapFactory.Options options = new BitmapFactory.Options();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
options.inMutable = true;
}
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap source = BitmapFactory.decodeResource(res, sourceResId, options);
Bitmap bitmap;
if (source.isMutable()) {
bitmap = source;
} else {
bitmap = source.copy(Bitmap.Config.ARGB_8888, true);
source.recycle();
}
bitmap.setHasAlpha(true);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
canvas.drawBitmap(mask, 0, 0, paint);
mask.recycle();
return bitmap;
}
source image=将是一个透明的字母“C”,来自像这样的可抽取项
蒙版图像应该来自CircularProgressView。我想使用CircularProgressView蒙版字母C,在点上用纯白填充透明字母“C”(比例为1/10)。可能吗