本文整理匯總了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);
}
}