Tuesday, March 13, 2012

Android Note: Scale the bitmap and keep aspect ratio

In the previous post, Matrix.postScale() is used to draw the bitmap, but the result is not perfect. The aspect ratio of prepared bitmap is 1.67 (480x800), when scale it and draw on the screen with 1.5 aspect ratio (320x480), the width will be stretched.
To keep the aspect ratio, we can use Matrix.ScaleToFit.CENTER .

Tuesday, March 6, 2012

Android Note: Draw once and scale to fit different screen size

When develops Game Apps, how to draw the UI to fit all devices with different screen size may be a problem.