Which resource structure to use for both Android t

2019-05-10 03:54发布

问题:

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