Wednesday, July 11, 2012

Learning about the Image Problem of Widget

Wanner Create a widget for fun and learning, Just Know that the image is re-sized incorrectly According to http://developer.android.com/guide/practices/screens_support.html The Nexus One has a DPI somewhere around 250 which puts it into the hdpi class. Using the google formula of (number of cells * 74) - 2 to calculate dp for your 1x1 widget would make the widget dimensions 72x72 dp. The conversion from dp to pixels is: pixels = dp * (density / 160) So for a 72x72 dp image, the corresponding image sizes based on density would be: ldpi (120 DPI) = 72 * (120 / 160) == 54 x 54 pixels mdpi (160 DPI) = 72 * (160 / 160) == 72 x 72 pixels hdpi (240 DPI) = 72 * (240 / 160) == 108 x 108 pixels Use these formulas to create your assets and you should get crisp images.

No comments:

Post a Comment