如何使 Canvas Imageview 点击下一步 activity

How to make Canvas Imageview click to next activity

imageView = (ImageView)findViewById(R.id.img);
imageView.setImageResource(R.drawable.aa);
// crash below into bitmap width and height > 0;
bitmap = Bitmap.createBitmap(imageView.getWidth(),imageView.getHeight(), Bitmap.Config.ARGB_8888);

canvas = new Canvas(bitmap);
// imageView.setImageBitmap(bitmap);
dw = imageView.getWidth();
dh = imageView.getHeight();

Log.e("bitmap", "bitmap" + imageView);
Log.e("canvas", "canvas" + canvas);
imageView.setOnTouchListener(this);
//imageView.setOnClickListener(this);
}

public boolean onTouch(View v, MotionEvent event) {

int action = event.getAction();
int x = (int) event.getX();
int y = (int) event.getY();

switch(action){
case MotionEvent.ACTION_DOWN:
     if (x >= dh && x < (dh + bitmap.getWidth())
     && y >= dw && y < (dw + bitmap.getHeight())) {
     }
break;
}
return true;
    }
}

崩溃时用下面的代码替换代码。

imageView.measure(0,0);
bitmap = Bitmap.createBitmap(imageView.getMeasuredWidth(),imageView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);

另外:

dw = imageView.getMeasuredWidth();
dh = imageView.getMeasuredHeight();