Which resource structure to use for both Android tablets and mobiles?

♀尐吖头ヾ 提交于 2019-12-22 10:34:53

问题


I updated my app's resources the last time when higher density devices came up. Started drawing my icons in higher resolution and supplied them through the use of the res/drawable-hdpi directory structure.

So far, so good.

Now I wanted to do some changes to adopt for Android tablets. Have updated a few layouts and then I slowly realized why all my icons looked somewhat strange to me on that nice display: the "normal" 10 inch tablets are not classified as hdpi, but mdpi thus all my "old" resources from former times re-appeared!

I wonder: how am I supposed to supply images for a tablet? Again, a new directory, something like drawable-large or xlarge? Not even would I have to duplicate all my identical resources, which is stupid, I also wonder why I should classify images for mdpi/hdpi on the one hand and for screen size on the other...

What is the preferred way that Android developers should go?

Thanks!


回答1:


you can specify an api level for the folders as will. For the app I just developed I had a folder called drawable-hdpi-v9 for all the new galaxy 10.1 icons.

So.. If you wish to have different icons or images for android version 2.3 and earlier versions put the icons for Android 2.3 and later in a resource folder with -v9 appended to the folder name. Example: drawable-hdpi-v9




回答2:


I agree with you! I'm currently using drawable-large-mdpi for tablets and drawable-hdpi for phones.

At the moment you have the following alternatives:

http://android-developers.blogspot.com/2011/09/preparing-for-handsets.html

http://android-developers.blogspot.com/2011/07/new-tools-for-managing-screen-sizes.html

http://developer.android.com/guide/market/publishing/multiple-apks.html



来源:https://stackoverflow.com/questions/6988045/which-resource-structure-to-use-for-both-android-tablets-and-mobiles

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!