Android menu icons
I have a menu item and icons for it in 36x36,48x48 and 72x72 pixel ratio sizes. 开发者_StackOverflow中文版Now, how do I make each icon render in specific cases. Is it possible to define that in xml file?
I guess you already saw this useful link:
http://developer.android.com/guide/practices/ui_guidelines/icon_design.html
All you need to do is to save different variants under different folders, but with the same name:
res/drawable-ldpi (36x36)
res/drawable-mdpi (48x48)
res/drawable-hdpi (72x72)
You refer to them in your code through common resource name, but actual version used is adapted depending on the screen size of the device you are using.
Note that http://developer.android.com/guide/practices/ui_guidelines/icon_design_menu.html#size9 gives a bit different icon sizes:
Menu icon dimensions for high-density (hdpi) screens:
Full Asset: 72 x 72 px
Icon: 48 x 48 px
Square Icon: 44 x 44 px
Menu icon dimensions for medium-density (mdpi) screens:
Full Asset: 48 x 48 px
Icon: 32 x 32 px
Square Icon: 30 x 30 px
Menu icon dimensions for low-density (ldpi) screens:
Full Asset: 36 x 36 px
Icon: 24 x 24 px
Square Icon: 22 x 22 px
If you use an icon of more than 48x48 on an hdpi screen, the user will not see the menu item title (or see a truncated title, which is even worse).
精彩评论