android - Select and place different shapes in canvas using OnTouch event -
i new android programming in project layout, need created
- color palette in grid layout(i put buttons , set color background).
- shapes(triangle,square , circle buttons well) in linear layout
- next these 2 relative layout users can draw shapes
when user touch on 1 of shape , touch on relative layout (which next shapes), particular shape should drawn , colors. example if user touch on circle shape, touch on screen, circle should drawn @ point user touched.
i managed create 2 touch events in 2 different classes, i.e 1 selecting shapes , other placing shapes in layout.
i have no idea how combine 2 classes together.
can please give me idea how should approach project. should create shapes (should create separate classes each shape/in ondraw()
)? if create shapes in ondraw()
how can call in ontouch()
?
any great. in advance.
i hope explained properly, sorry not in english , first time posting in forum.
generally draw shapes on canvas touch event, used code below, may you.
@override protected void ondraw (canvas canvas) { super.ondraw(canvas); canvas.save(); canvas.drawbitmap(mbitmap, 0, 0, null); canvas.translate(xpos, ypos); editicon.draw(canvas); canvas.restore(); // invalidate(); } @override public boolean ontouchevent (motionevent event) { switch (event.getaction()) { case motionevent.action_down : xpos = event.getx(); ypos = event.gety(); invalidate(); // add here break; } return true; }
check example also,
http://android-er.blogspot.in/2010/05/android-surfaceview.html
Comments
Post a Comment