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

7

6

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?

Amniocentesis answered 4/2, 2015 at 8:44 Comment(7)
Both of them are xhdpi. Why do you have all-caps text at the end?Madewell
@Madewell both are not xhdpi. samsung 10 inch tab is with mdpi .. please check this gsmarena.com/samsung_galaxy_tab_2_10_1_p5100-4567.php even by code if we gt m gttng MDPI.. why last text are in caps ? bcz jst to mentioned things ... why is there any prob with that .. thn pls let me know i will make those to small...if any problem with current format ....Amniocentesis
Don't use all-caps in normal text. It's the equivalent of shouting in writing. Don't use txt-speak either, as that makes it harder to read. Just use normal English and formatting. As for the problem, I have no idea then, sorry. I was looking at the Pro version.Madewell
Okay thanks a lot :) .. Pls provide the link or smthng where I can learns this type of things.. Means knowledge what u have where I read or gain that.. It will b helpful to me.. Np if u dnt have any answer for this question...Amniocentesis
stackoverflow.com/help/how-to-askMadewell
@ozbek thanks for editing.. and formating question .. it will helpful to me in future when m gng to post question .. :) thanks a lotAmniocentesis
Hay did you find any answer and working solution. I have to face same difficultyAmberly
O
8

You can use drawable folders in this format:

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

etc

Obbligato answered 6/2, 2015 at 11:42 Comment(3)
Hello Thanks for the reply :) ...I have already tried with tht way. But if i go with that i hve create drawable like drawable-1280x800(Samsung Tab 10) , drawable-2560x1600(N10) drawable-1200x1920(N 7 [2013]) it gives error and wont allow me to build resource.ap_ bcz dir structure is nt acceptable eror like (invalid resource directory name:\res drawable-1200x1920)Amniocentesis
is there any other way out ?Amniocentesis
will this work for resource folder ? I designed a app for "Samsung Galaxy Tab 10 inch" and now the requirement is I have to support also for "Mi Tab 7.9 inch". Both are "xhdpi" so how to keep different drawables and resource folder for these two devices ?Mutant
C
2

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>
Conduit answered 11/2, 2015 at 8:59 Comment(2)
thanks for the input .. i'll try bt things where i need to implementh your trick wont be consider proper solution.. i guess this is not a perfact solution .. it will create same image (with different resolution) will have two different resource entry which is not proper i guess.. do you have any idea about the dir structure provided by android natively ...Amniocentesis
No idea.. the problem occurs just because the android native dir structure do not work.Conduit
C
1

If you are using Android studio, you can right-click resource folder New-> Android resource folder.You will see all available conditions for drawable folders, including screen size.Also you can choose multiply conditons. Probably same will for Eclipse, but i hadnt tested this.

Checkrow answered 12/2, 2015 at 8:23 Comment(1)
yes thanks .. tried man once check the answer .. i've described all things what i tried .Amniocentesis
G
0

One thing that might work is using a different smallest width (assuming they are different for the 10" and 10.1" device).

To do this, use an app to get the exact smallest width, for instance: https://play.google.com/store/apps/details?id=com.jotabout.screeninfo

If they are different, you can simply use them as the -swxxxdp qualifier.

Note that the smallest width qualifier doesn't need to be a round number, it can be anything: sw800dp, sw801dp, sw802dp,...

Gulledge answered 10/2, 2015 at 7:8 Comment(2)
thanks for the input. but i hve already get the smallest width for the device and based on that i have created the dir. and its sw800 and based on that i hve created drawable folder here the issue is with density also..Amniocentesis
So the smallest width for both the Nexus 10 and the Galaxy tab are exactly equal to 800dp? (I'm talking about the exact smallest width, measured on the device, not the folder they seem to be using) Is that something you actually verified by calculating it on the device or did you figure that out by renaming folders in eclipse until it worked?Gulledge
W
0

You have to Clean the project after renaming the resource folders, otherwise the R object will not be regenerated which will make your app use the old references.

Something like you have done here goes in the correct direction :

I also tried to use drawable-xlarge-mdpi and drawable-xlarge-xhdpi (removed drawable-sw800dp-mhdpi & drawable-sw800dp-xhdpi)

(I hope you haven't spelled it "mhdpi" like you have done in your post though)

Westfall answered 12/2, 2015 at 21:13 Comment(2)
thanks for the response :) . yes tht was typo mistake i've updated that. cleaning and building project wont work even. and you can see rest of all place its mdpi only not mhdpi.Amniocentesis
if possible thn cme without restart IDE , clean app, build app, delete R.java and regenerate etc ...as i already did all things dozens of timesAmniocentesis
T
0

A set of six generalized densities: ldpi (low) ~120dpi mdpi (medium) ~160dpi hdpi (high) ~240dpi xhdpi (extra-high) ~320dpi xxhdpi (extra-extra-high) ~480dpi xxxhdpi (extra-extra-extra-high) ~640dpi

And

xlarge screens are at least 960dp x 720dp large screens are at least 640dp x 480dp normal screens are at least 470dp x 320dp small screens are at least 426dp x 320dp

Please refer

http://developer.android.com/guide/practices/screens_support.html

Tyndale answered 13/2, 2015 at 9:37 Comment(2)
thanks for the input ...? bt can u please tll me about dir name which wil handle the case which i hve mentioned ..?Amniocentesis
I know that there are folders for drawable with names drawable-small, drawable-normal, drawable-large and drawable-xlarge. As per my knowledge drawable-xlarge is suitable for 10 inch devices. But I am not sure preference will be given to resolution or screen size. remove resolution drawables and check. if that works, drawable-xlarge-mdpi and drawable-xlarge-hdpi and all should work. Unfortuantely I dont have device to test that. :) And please don't give exact screen size for the max like sw600 etc.Tyndale
M
0

Try to use Configuration qualifiers for your resources drawable folder for tablet version.

drawable-sw600dp (for 7" devices)
drawable-sw720dp (for 10" devices)
drawable-sw600dp-land (for 7" devices with landscape mode) drawable-sw720dp-land (for 10" devices with landscape mode)

Malikamalin answered 14/9, 2016 at 9:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.