Skip to content Skip to sidebar Skip to footer

Canvas.drawline() Not Appearing On Bitmap

I have tried so many methods but still my code refuses to simply draw a line on the canvas. Each of the attempts I have commented out either crash the program or won't display the

Solution 1:

You need to create the Bitmap as a Drawble object and then draw on that bitmap not on to the canvas it self.

So basically you create an object of BitmapDrawable with the help of Bitmap object that you have created with the help of BitmapFactory option. You will have to use the draw(Canvas c) method of this Drawable class to draw on the bitmap.

http://developer.android.com/reference/android/graphics/drawable/BitmapDrawable.html

Solution 2:

I needed to add paint = new Paint() in onCreate. Paint object was null so that's why it wouldn't draw. Took me weeks and a ridiculous amount of pestering just to spot that! I'm going on vacation...

If anybody plans on making a project like this I intend to make some youtube video tutorials in the near future to help anyone from falling into the same stupid pitfalls that I did!

Many thanks to user_CC too for all his time and help on this question!

Post a Comment for "Canvas.drawline() Not Appearing On Bitmap"