Drawing Image on Canvas and maintain aspect ratio

Problems with Canvas, OpenGL, etc...

Drawing Image on Canvas and maintain aspect ratio

Postby gogodev » Mon Nov 08, 2010 6:21 pm


I am new to android development. So pardon me if it is something very straightforward. I am trying to design a slide-show application. This application fetches images from my web-server. Many of these images are varying in size and in aspect ratio. I want to show each image on the screen as large as possible (without going beyond the screen and also maintaining the picture's aspect ratio). For the record I am drawing the image on canvas. What is the best way to go about doing this? If there are pointer's to sample application, I can take those and follow-up.

I have reviewed http://code.google.com/p/android-slideshow/. While this project is pretty neat, the image-scaling in this project does not seem to be optimal.

Thanks in Advance!!
Posts: 2
Joined: Mon Nov 08, 2010 4:52 pm


Re: Drawing Image on Canvas and maintain aspect ratio

Postby Schermvlieger » Mon Nov 08, 2010 7:05 pm

Hi Gogodev,

Check out the ImageView class on the developers reference site:

http://developer.android.com/reference/ ... eView.html

You can use ScaleType to control how the image is scaled inside the view.
Senior Developer
Senior Developer
Posts: 159
Joined: Fri Feb 26, 2010 1:37 pm


Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: Google [Bot] and 1 guest