Drawables for qHD resolution

2019-05-27 12:13发布

问题:

I'm designing a game possibly for all kinds of Android devices, so I have multiple drawable folders for phones of different resolutions, and for tablets. Here is the list of my folders:

  • drawable-mdpi - for 480x320 devices
  • drawable-hdpi - for 800x480 and 854x480 devices
  • drawable-large-hdpi - for 1024x600 tablets
  • drawable-xlarge-mdpi - for 1200x800 tablets

My question is what name should have a folder with drawables for qHD resolution, which is 960x540 and 256 dpi? Thanks in advance.

回答1:

I will deeply, strongly, emphatically encourage you not to use "-large" or "-xlarge" qualifiers with drawables. If you are doing this, you are almost certainly not doing what you think you are.

For example.

"drawable-large-hdpi" does not mean "1024x600 tablets." It means an hdpi screen that is classified as large. There are a huge number of screen sizes that fit in this category. In fact you will soon be seeing 1024x600 mdpi tablets.

And "drawable-xlarge-mdpi" does not mean "1200x800 tablets." First of all, tablets like the Xoom are actually 1280x800. And other possible resolutions here are 1280x720, 960x720, 1920x1200, and on and on and on.

If you are doing this kind of thing, let me suggest: just write some code instead. If you have a set of drawables that you want to pick to best match the space you have available in your UI, write some code that looks at the space it has available and picks a drawable. And when you do this, don't use Display.getDisplayMetrics(). Implement this based on the space actually given to your appropriate view in the view hierarchy.

Now all that said, qHD screens are generally hdpi normal size.

So, another example: "drawable-hdpi" doesn't have anything to do with a resolution at all. Possible resolutions you will see here: 800x480, 640x480, 960x540, and on and on. \