0

n my application, I want to set different font size and paddings for different mobile devices. I use this method explain in Android documentation.

res/layout/my_layout.xml             // layout for normal screen size ("default")
res/layout-small/my_layout.xml       // layout for small screen size
res/layout-large/my_layout.xml       // layout for large screen size
res/layout-xlarge/my_layout.xml      // layout for extra large screen size
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation

i use galaxy s2 and htc one for the testing , it seems no matter what folder i create it allways use the xml from the res/layout/

i added this in manifest

<supports-screens android:smallScreens="true" 
      android:normalScreens="true" 
      android:largeScreens="true"
      android:xlargeScreens="true"
      android:anyDensity="true" />

how can i make sure the galaxy and htc one will use different xml ? instead the current situation that they both use the default layout .

Jesus Dimrix
  • 4,378
  • 4
  • 28
  • 62

3 Answers3

1

Galaxy S2 uses folder :

layout-normal-hdpi

HTC One uses folder :

layout-normal-xxhdpi

manifest :

<supports-screens android:smallScreens="true" 
      android:normalScreens="true" 
      android:largeScreens="true"
      android:xlargeScreens="true"
      android:anyDensity="true" />
Jesus Dimrix
  • 4,378
  • 4
  • 28
  • 62
0

First you will paste this code in your mainfest file

<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:resizeable="true"
    android:smallScreens="false"
    android:xlargeScreens="true" 
   />

<compatible-screens>
    <screen
        android:screenDensity="ldpi"
        android:screenSize="small" />
    <screen
        android:screenDensity="mdpi"
        android:screenSize="normal" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="large" />
    <screen
        android:screenDensity="xhdpi"
        android:screenSize="xlarge" />        
</compatible-screens>

And then delete the layout file in res folder because it will automatically take the default screen for all..So

An then you can specify the values for all screen size like this...

      res/values-small/my_layoutvalues.xml       // layout for small screen size
      res/values-large/my_layoutvalues.xml       // layout for large screen size
      res/values-xlarge/my_layoutvalues.xml      // layout for extra large screen size
      res/values-xlarge-land/my_layoutvalues.xml //layout for extra large in landscape orientation

that's all if you need any clarification comment...

Naveen Kumar Kuppan
  • 1,424
  • 1
  • 10
  • 12
  • for like this errors you can mention SW values in your res folder...like layout-sw420dp,layout-sw720dp,layout-sw600dp,etc – Naveen Kumar Kuppan Mar 20 '14 at 03:54
  • You can classify the values for this problem but Android is only supporting the 4,4.7,7,10 inches screen only if you want design other then this screen you go with dynamic adjustments only... – Naveen Kumar Kuppan Mar 20 '14 at 03:58
0

for phones upto 5'1" screen

use layout folder only
Note: use linear layout as parent layout and use weights as weight divide each screen 
in equal parts

for 7" tablet

layout-sw600dp-port //for portrait mode
layout-sw600dp-land //for landscape mode

for 10" tablet

layout-sw720dp-port //for portrait mode
layout-sw720dp-land //for landscape mode
Pankaj Arora
  • 10,224
  • 2
  • 37
  • 59