Problem with dedicated resources for Android

I noticed that the real device selects another resource from this eclipse in the preview. For example, I created available resources for devices with the smallest width of 720dp as

  • drawable-sw720dp-mdpi for Samsung Galaxy Tab 1280x800 mdpi
  • drawable-sw720dp-hdpi for Nexus 10 2560x1600 hdpi.

But does the Samsung Galaxy Tab 1280x800 mdpi raise drawable-sw720dp-hdpi instead of drawable-sw720dp-mdpi ?

Same thing with other devices. If there are resources drawable-sw320dp-hdpi , drawable-sw320dp-xhdpi , Sony Ericsson xperia-ARC 854x480 hdpi raises drawable-sw320dp-xhdpi ?

I cannot save the drawable-hdpi resource because there is a 5'5 inch screen size. For example, samsung galaxy 1280x720 hdpi is 5'5 inches, and for such devices there is a different graphic design, so both 854x480 hdpi and 1280x720 hdpi devices will use the same drawable-hdpi wich not acceptable.

Any ideas?

+4
source share
2 answers

Some time ago, I had a similar problem when writing animated wallpapers that used canvas and bitmap images. I could not achieve what I wanted using the default layout folders.

In my case, for example, a medium-density device with an xlarge screen (1280x800) should use the same resources as a high-density device with a regular screen (600x1024).

I decided to write my own solution, placing resources in three groups and selecting them using custom rules.

 DisplayMetrics metrics = resources.getDisplayMetrics(); int screenSize = resources.getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK; switch (metrics.densityDpi) { case DisplayMetrics.DENSITY_LOW: if (screenSize == Configuration.SCREENLAYOUT_SIZE_SMALL || screenSize == Configuration.SCREENLAYOUT_SIZE_NORMAL) { return new SmallResourceProvider(resources); } case DisplayMetrics.DENSITY_MEDIUM: if (screenSize == Configuration.SCREENLAYOUT_SIZE_NORMAL) { return new MediumResourceProvider(resources); } default: return new LargeResourceProvider(resources); } 

Perhaps this will be useful in your case.

0
source

I also ran into the same weird problem. In my case, the Galaxy GT P7500 tab was collecting images from the drawable-sw720dp-XXHDPI folder, since I also had the XXHDPI folder. If I delete XXHDPI, it will pick up the following below which is the XHDPI folder.

The problem is with the swxxxdp qualifier for selected folders. If I remove the width of the screen and use only one set of images of all densities, the problem seems to be solved. However, I wanted to have a different set of drawings for 7-inch and 10-inch devices. I used a different set of names for 10-inch images and 7-inch images and used 2 different sets of layouts with the sw600dp and sw720dp qualifiers. Here is my current structure that works well. However, this is not the expected way to use resources, since the Android recommends screening drawings . Unfortunately, I could not find a better solution.

 layout-land layout-sw600dp-land (uses image.png) layout-sw720dp-land (image_large.png) 

and for links,

 drawble-mdpi (image.png & image_large.png) drawable-hdpi drawable-xhdpi drawable-xxhdpi 
0
source

Source: https://habr.com/ru/post/1491090/


All Articles