开发者

How to get application's hdpi icons on Android API 11 tablets and more (in the java code)?

I have noticed on the Motorola xoom, that the applications icons on the Launcher are 72px by 72px. This is normally the size of icons defined in drawable-hdpi/ in packages.

In my application I want to display the icons of some installed applications on that 72x72px size. I currently fetch the icons of installed apps via the PackageManager, but it returns me bitmaps of inferior size (46px), which corresponds to the resources de开发者_JAVA技巧fined in drawable-mdpi/ of each package. This is not acceptable for me as I would like to display these icons in a larger format.

Apparently the 10" screen of the Motorola xoom is 160dpi, thus mdpi and xlarge (see http://developer.android.com/guide/practices/screens_support.html#range). This would explain the behaviour of PackageManager returning me mdpi resouces instead of hdpi resources.

How could I get the icons of installed applications in a size of 72x72px minimum? Does anyone knows how it was done in the Launcher application on Android Honeycomb?

Thanks, Laurent


You can create special sub-folder in your res folder and call it like drawable-large-v11, or drawable-large-v11, or other name suitable for your application.

Then copy large icon to that sub-folder, but filename must be the same as in other folders for different dpi's. I've used such approach in my applications and it works great.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜