本文整理汇总了Java中android.graphics.Paint.getXfermode方法的典型用法代码示例。如果您正苦于以下问题:Java Paint.getXfermode方法的具体用法?Java Paint.getXfermode怎么用?Java Paint.getXfermode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Paint
的用法示例。
在下文中一共展示了Paint.getXfermode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onDraw
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
Drawable drawable = getDrawable();
if (drawable instanceof BitmapDrawable) {
RectF rectF = new RectF(drawable.getBounds());
int restoreCount = canvas.saveLayer(rectF, null, Canvas.ALL_SAVE_FLAG);
getImageMatrix().mapRect(rectF);
Paint paint = ((BitmapDrawable) drawable).getPaint();
paint.setAntiAlias(true);
paint.setColor(0xff000000);
canvas.drawARGB(0, 0, 0, 0);
canvas.drawRoundRect(rectF, RADIUS, RADIUS, paint);
Xfermode restoreMode = paint.getXfermode();
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
super.onDraw(canvas);
// Restore paint and canvas
paint.setXfermode(restoreMode);
canvas.restoreToCount(restoreCount);
} else {
super.onDraw(canvas);
}
}
示例2: onDraw
import android.graphics.Paint; //导入方法依赖的package包/类
@Override
protected void onDraw(Canvas canvas) {
Drawable maiDrawable = getDrawable();
if (!isInEditMode() && maiDrawable instanceof BitmapDrawable) {
Paint paint = ((BitmapDrawable) maiDrawable).getPaint();
Rect bitmapBounds = maiDrawable.getBounds();
rect.set(bitmapBounds);
int saveCount = canvas.saveLayer(rect, null,
Canvas.MATRIX_SAVE_FLAG |
Canvas.CLIP_SAVE_FLAG |
Canvas.HAS_ALPHA_LAYER_SAVE_FLAG |
Canvas.FULL_COLOR_LAYER_SAVE_FLAG |
Canvas.CLIP_TO_LAYER_SAVE_FLAG);
getImageMatrix().mapRect(rect);
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
final int color = 0xffffffff;
paint.setColor(color);
canvas.drawPath(boundPath, paint);
Xfermode oldMode = paint.getXfermode();
paint.setXfermode(duffMode);
super.onDraw(canvas);
paint.setXfermode(oldMode);
canvas.restoreToCount(saveCount);
drawHover(canvas);
drawBorder(canvas);
} else {
super.onDraw(canvas);
}
}