in my overridden onDraw() function i have a canvas with two gauges in it (gauges are PNG's). The gauges are stacked on top of eachother. I would like only half of the gauge on the top to show while revealing the bottom gauge on the other half. Here's what i have so far:
@Override
public void onDraw(Canvas c){
int targetWidth=200;
int targetHeight=200;
Paint p = new Paint();
Bitmap bottom = BitmapFactory.decodeResource(getResources(), R.drawable.dashboard_rpm_bottom);
Bitmap top = BitmapFactory.decodeResource(getResources(), R.drawable.dashboard_rpm_top);
p.setFilterBitmap(false);
c.translate(55,320);
c.drawBitmap(
bottom,
new Rect(0, 0, bottom.getWidth(), bottom.getHeight()),
new Rect(0, 0, targetWidth, targetHeight),
p);
p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));
c.drawBitmap(
top,
new Rect(0, 0, top.getWidth(), top.getHeight()),
new Rect(0, 0, targetWidth, targetHeight),
p);
}
doesn't seem to work, anyone have any ideas?
I was able to do this using the xfermode DST_OUT method