问题
I am new in android. I reviewed two examples Custom View with User Interaction and Android SurfaceView. I want that in second example draw cicle similarly with first example. How I can do this? Second question is: when the run() method has to stop?
回答1:
I found solution. For correctly work of SurfaceView I had to set background of canvas. When I done it everything is working fine.
回答2:
Create A bitmap then draw on its canvas and then add this bitmap to an imageview.
Create A bitmap:
Bitmap bmp = Bitmap.createBitmap(width, height, config);
Draw on the bitmap canvas
Canvas cv = new Canvas(bmp);
cv.drawCircle(cx, cy, radius, paint)
setting to imageview
img.setBackgroundDrawable(new BitmapDrawable(bmp));
Hope his help you.
来源:https://stackoverflow.com/questions/14139177/android-surfaceview-drawing