I just want a layout folder for 21 inch screen.I have sw600dp for 7 inch tablet and sw720dp layout folder for 10 inch tablet.how i specify folder for hp slate 21 inch tablet in android?thanks in advance
Asked
Active
Viewed 533 times
3
-
Check this. http://stackoverflow.com/questions/19316888/android-setting-for-tablets – Mitesh Shah Oct 16 '13 at 12:50
-
@android_beginner: i know the display screen size 1920 x 1280 pixel so what will be name of layout folder should i use? – Sharad Mhaske Oct 16 '13 at 12:56
-
Check this link : http://developer.android.com/training/tv/index.html just out of curiosity, can u share a link to see 21 inch tablet.? – SKK Oct 16 '13 at 12:59
-
@santosh:http://h20435.www2.hp.com/t5/The-Next-Bench-Blog/Slate21-Android-Lands-on-One-Awesome-All-in-One/ba-p/81757 this is link – Sharad Mhaske Oct 16 '13 at 13:03
-
Hi, Have you found how to do it? – sourcerebels May 28 '14 at 09:07
-
@SharadMhaske. Have you found the solution. – Balaji Dhanasekar Oct 20 '14 at 13:27
-
@BalajiDhanasekar.nope1 – Sharad Mhaske Oct 30 '14 at 05:49
-
@SharadMhaske. Am trying a lot for this. I don't know what layout and drawable to use and how to test it. Do you have any suggestions. Please comment. – Balaji Dhanasekar Nov 04 '14 at 10:36
-
1you can do one thing.have your 21inch layouts in default layout folder and need to calculate the screen size in inch then set the layout from default layout folder for that you need to have diff name for layout files so that it will pick it from default layout folder. – Sharad Mhaske Nov 06 '14 at 06:20
-
1or use layout_weight for layout so that it will adjust according to size so that you dont need to give different layout folder.hope this helps you. have a try. – Sharad Mhaske Nov 06 '14 at 06:22
-
Yes Exactly. I too tried the layout_weight and it works. Thanks. – Balaji Dhanasekar Jan 08 '15 at 11:11
3 Answers
0
If you know the resolution (or roughly) of the screen you can work out the dp folder you'll need.
px = dp * (dpi / 160)

TMH
- 6,096
- 7
- 51
- 88
-
i got this display of devices so 1920 by 1080 pixel so what will be the name of layout folder? – Sharad Mhaske Oct 16 '13 at 12:54
0
See http://developer.android.com/guide/topics/resources/providing-resources.html . sw720dp means smallest width 720dp, so this will be used by all devices having a smallest width of 720dp or more.

Ridcully
- 23,362
- 7
- 71
- 86
-
-
sw720dp does not mean you get a layout thats 720dp wide. Layouts in Android always adopt to the available screen size. It's just that you can provide a different layout here for large screens and provide another one for handheld devices in the default layout folder. – Ridcully Oct 16 '13 at 18:19
-
-
-
i have layout folder layout-sw720 for 10 inch tablet as i have very big layout for 21 inch screen which may not look good on 10 inch screen. – Sharad Mhaske Oct 17 '13 at 09:06
-
You don't get it, do you? Android stretches each layout so it fills the available space. You can run the same app with the same layout on a 3.5'' screen as well as on a 21'' screen and it will always fill up all the screen space. The different layout-
folders are only there if you want to provide a separate layout, e.g. with two columns instead of one, for larger screens. – Ridcully Oct 17 '13 at 16:06 -
what about the dimensions of diff view?i dont want same dimension on 21 inch screen.i know layout will streches but i dont want that right? – Sharad Mhaske Oct 18 '13 at 03:38
-
Well, you can go with a layout-w1024dp and replace the 1024 by the dp-value of the 21'' screen. To calculate that value you'll need the device's resolution as well as the size. According to the link you posted, the device has a resolution of 1920 by 1080 pixels on a 21.5'' 16:9 screen. This means it has a width of 18.73'' which gives us a resolution of (only) 102dpi, and thus, according to http://developer.android.com/guide/practices/screens_support.html would use the layout-ldpi! – Ridcully Oct 18 '13 at 11:32
-
:their is nothing like layout-w1024dp as it gives error.i think google has not specified the layout folder for 21 inch screen specifically. – Sharad Mhaske Feb 27 '14 at 07:34
-
@Ridcully. I too have the same problem. Could you please provide me a solution. – Balaji Dhanasekar Oct 21 '14 at 11:05
0
Just add the below code in somewhere your Activity
and run the application in that device, you will get the value of smallestWidthDp.
suppose if you get it 800 then you need to create layout folder named layout-sw800dp
Configuration mConfig = this.getResources().getConfiguration();
if (Build.VERSION.SDK_INT >= 13) {
int smallest_width_dp_value = mConfig.smallestScreenWidthDp;
Log.e("smallestWidthDp",smallest_width_dp_value+"");
}

Mehul Joisar
- 15,348
- 6
- 48
- 57
-
i dont have that device for testing that is the pbm i m facing.its hp slate 21 tablet – Sharad Mhaske Oct 16 '13 at 14:27