如何增加Android手指触摸动作的进度条?

时间:2014-05-30 05:44:38

标签: android

我已经实现了一个代码,可以在触摸时显示背面图像。触摸手指移动后方图像视图显示区域和前方图像视图变得不可见。我只想要手上的磨砂按摩我的代码在这里可以任何人建议我如何做到这一点..

public class StartActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(new TouchView(this));

}

class TouchView extends View {
    Bitmap bgr;
    Bitmap overlayDefault;
    Bitmap overlay;
    Paint pTouch;
    int X = -100;
    int Y = -100;
    Canvas c2;

    public TouchView(Context context) {
        super(context);

        bgr = BitmapFactory.decodeResource(getResources(), R.drawable.bgr);
        overlayDefault = BitmapFactory.decodeResource(getResources(),
                R.drawable.over);
        overlay = BitmapFactory.decodeResource(getResources(),
                R.drawable.over).copy(Config.ARGB_8888, true);
        c2 = new Canvas(overlay);

        pTouch = new Paint(Paint.ANTI_ALIAS_FLAG);
        pTouch.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT));
        pTouch.setColor(Color.TRANSPARENT);
        pTouch.setMaskFilter(new BlurMaskFilter(15, Blur.NORMAL));

    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {

        switch (ev.getAction()) {

        case MotionEvent.ACTION_DOWN: {

            X = (int) ev.getX();
            Y = (int) ev.getY();
            invalidate();

            break;
        }

        case MotionEvent.ACTION_MOVE: {

            X = (int) ev.getX();
            Y = (int) ev.getY();
            invalidate();
            break;

        }

        case MotionEvent.ACTION_UP:

            break;

        }
        return true;
    }

    @Override
    public void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        // draw background
        canvas.drawBitmap(bgr, 0, 0, null);
        // copy the default overlay into temporary overlay and punch a hole
        // in it
        c2.drawBitmap(overlayDefault, 0, 0, null); // exclude this line to
                                                    // show all as you draw
        c2.drawCircle(X, Y, 80, pTouch);
        // draw the overlay over the background
        canvas.drawBitmap(overlay, 0, 0, null);

    }

}}

请帮忙....

0 个答案:

没有答案