Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define drawable folder name for multiple screen resolutions (conflict between Nexus 10 and Galaxy Tab 10)?

Following folder structure is working fine for the mentioned devices and resolutions:

  • drawable-hdpi -- for 480x800
  • drawable-ldpi -- empty
  • drawable-mdpi -- for 320x480 and 240x320 (mdpi device)
  • drawable-sw600dp-tvdpi -- for Nexus 7 2012 tvdpi
  • drawable-sw600dp-xhdpi -- for Nexus 7 2013 xhdpi

The problem is with the Nexus 10 and Samsung Galaxy Tab 10 (Tab is with Android 4.0 & mdpi). To handle both devices I added two separate drawable folders:

  • drawable-sw800dp-xhdpi -- for Nexus 10 (put 2560x1600 resolution images to this folder)
  • drawable-sw800dp-mdpi -- for Samsung Galaxy Tab 10 (put 1280x800 resolution images to this folder)

However, both Nexus 10 and Samsung Galaxy Tab 10 are using images from drawable-sw800dp-xhdpi.

What else did I try?

  • drawable-sw720dp-xhdpi -- for Nexus 10
  • drawable-sw720dp-mdpi -- for Samsung Galaxy Tab 10

Similar result, both Nexus 10 and Samsung Galaxy Tab 10 are using images from drawable-sw720dp-xhdpi.

I also tried to use drawable-xlarge-mdpi and drawable-xlarge-xhdpi (removed drawable-sw800dp-mdpi & drawable-sw800dp-xhdpi) to handle Samsung Galaxy Tab 10 but Tab is with Android 4.0 and xlarge structure is deprecated. So it is taking according to the new directory structure (i.e., drawable-sw600dp-xhdpi).

Other related stuff

In Eclipse graphical layout editor correct images (from drawable-sw800dp-mdpi) are shown after selecting 10.1" WXGA (Tablet) which is like Samsung Galaxy Tab 10. However, when I test the same thing in device or emulator it is showing images from drawable-sw800dp-xhdpi.

Manifrest:

<uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

Layout:

layout

values:

values
values-sw320dp
values-sw600dp
values-sw800dp
  • Separate drawable folder is required because some of the images can not be converted into 9 patch images.
  • Please my question is not about conflicts between nexus 7 and nexus 10 or not between Samsung Galaxy Tab 7' and Samsung Galaxy Tab 10'.

The question

So what should be the drawable folders for Nexus 10 and Samsung Galaxy Tab 10?

like image 588
user1140237 Avatar asked Feb 04 '15 08:02

user1140237


2 Answers

You can use drawable folders in this format:

drawable-480x320
drawable-1280x800
drawable-2560x1600
...

etc

like image 157
Oguz Ozkeroglu Avatar answered Oct 04 '22 00:10

Oguz Ozkeroglu


To solve the problem of mdpi tablet load the resource inf "drawable-sw720dp-xhdpi", use this way:

The drawable names "R.drawable.ic_xxx";

drawable-xhdpi put your Nexus 10 pic, named as ic_xxx_720.png;

drawable-mdpi put your Samsung Galaxy Tab 10 pic, named as ic_xxx_720.png;

then in values-sw720dp put resource alias:

<item name="ic_xxx" type="drawable">ic_xxx_720.png</item>
like image 27
BenC Avatar answered Oct 03 '22 23:10

BenC