Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old December 28th, 2009, 04:34 PM   #1 (permalink)
New Member
 
Join Date: Nov 2009
Posts: 5
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default Draw on canvas (SurfaceView)

Hi, I'm trying to do easy app for draw on screen. I followed the tutorial on Graphics | Android Developers.
In my onTouchEvent method I have:
Code:
_canvas = holder.lockCanvas();
		if (event.getAction() == MotionEvent.ACTION_DOWN) {
			_path = new Path();
			_path.moveTo(event.getX(), event.getY());
			_path.lineTo(event.getX(), event.getY());
		} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
			_path.lineTo(event.getX(), event.getY());			
			_canvas.drawPath(_path, mPaint);
			_path = new Path();
			_path.moveTo(event.getX(), event.getY());
		} else if (event.getAction() == MotionEvent.ACTION_UP) {
			_path.lineTo(event.getX(), event.getY());
			_canvas.drawPath(_path, mPaint);
		}		
		holder.unlockCanvasAndPost(_canvas);
But when I draw, it shows something like that:

so I draw another lines and image changes to


In constructor of my MySurface class (which extends SurfaceView and implements SurfaceHolder.Callback) i set up holder variable:
Code:
		holder = getHolder();
		holder.addCallback(this);
Does anybody know what is wrong?

hollowback is offline  
Last edited by hollowback; December 29th, 2009 at 02:50 AM.
Reply With Quote
Sponsors
Old April 4th, 2012, 08:33 PM   #2 (permalink)
New Member
 
Join Date: Apr 2012
Posts: 1
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

man, I'm having the same problem.
you managed to solve?

thank you
Macrex is offline  
Reply With Quote
Old April 4th, 2012, 09:24 PM   #3 (permalink)
Senior Member
 
Join Date: Jul 2010
Posts: 977
 
Device(s): Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Thanks: 52
Thanked 199 Times in 144 Posts
Default

Have you tried running it on a physical device? Anything related to graphics tends to either work poorly or simply not work at all on the AVD.
jonbonazza is online now  
Reply With Quote
Reply

Bookmarks


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing Linear Layout on SurfaceView XxAP0STLExX Android Applications 0 December 4th, 2010 07:16 PM
Draw on SurfaceView(VideoPlayer) Canvas sapegas Application Development 0 November 4th, 2010 01:03 AM
Redrawing a portion of a surfaceView ophanin Application Development 1 July 20th, 2010 09:29 AM
Add Button to SurfaceView safibaba Application Development 0 June 17th, 2010 09:50 AM
surfaceview setbackgrounddrawable() mrqs Application Development 1 March 19th, 2010 11:22 AM



All times are GMT -5. The time now is 11:39 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo