Android Alpha Masking问题

问题描述

| 在我覆盖的onDraw()函数中,我有一个带有两个标尺的画布(标尺为PNG \)。量规彼此堆叠。我只想显示顶部的一半,而另一半则显示底部。这是我到目前为止的内容
@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,bottom.getWidth(),bottom.getHeight()),targetWidth,targetHeight),p);


    p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OUT));

    c.drawBitmap(
            top,top.getWidth(),top.getHeight()),p);



    }
似乎没有用,有人有什么主意吗?     

解决方法

我能够使用xfermode DST_OUT方法执行此操作