Android Scaled Drawing to ImageView

Posted by user329999 on Stack Overflow See other posts from Stack Overflow or by user329999
Published on 2010-05-19T03:57:55Z Indexed on 2010/05/19 4:00 UTC
Read the original article Hit count: 389

Filed under:
|
|

Newbie question, so there's probably a simple answer to this problem.

I'm drawing some simple shapes using canvas.drawCircle(), canvas.drawLine() etc. I originally copied the code from:

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/DrawPoints.html

Which extends a View and draws directly to a canvas. It doesn't load a pre-drawn bitmap because I need my application to turn data into a drawing and the user will enter the data.

My changes work, but the drawing is too small (or big) and doesn't fill the screen using all the available screen. Ideally I'd rather use something like an ImageView in .XML like so:

If that's possible. The documentation seems to imply that I want to set the scaleType as shown in the above .XML which seems like the simple way to do this.

If using an ImageView in .XML is a good idea, then I'm lost on how to draw to the ImageView and could use some guidance on doing that task. If that won't work, then I'll need to do some more thinking about how to get my drawing scaled on the screen and basically I'm lazy and would rather have Android do the work for me. Feel free to suggest some other way that's completely different is this is the wrong solution path. :)

Thanks.

© Stack Overflow or respective owner

Related posts about android

Related posts about drawing