Reputation: 271
Hi I am new to Android Canvas. I want to know how can I draw on canvas using a bitmap.
Basically I want to be able to draw multiple figures in my canvas dynamically. After reading about canvas I figured out this much that for each figure I may have to create a new bitmap attach a canvas to it draw a figure in that bitmap and finally draw that bitmap in the canvas of onDraw()
method using drawBitmap
function in order to view it on screen. Hope I am right till this part ? If not please correct me. I am open for your opinions and suggestions :)
Also I would like to know if I can apply onTouch
event separately to the bitmaps or canvas created dynamically or it can be only applied to canvas of onDraw
cause I want the images which are being drawn in my canvas to be able to move at users will?
Upvotes: 2
Views: 112
Reputation: 3596
You are right about the first part. However in second part u cannot add onTouch listener as u have said. As far as I know listeners can only be added to Views. And also its not like you are adding onTouch Listener to the canvas of the onDraw() method u are basically applying to the whole view a view cannot have two same listeners.
Upvotes: 1