0

I am designing for supporting multiple screen size application using dip like margin_top etc. in 3.2. What are the folders I have to create for the value folder? Where do I have to specify dip? Can anybody tell me how to do this? If I had given value-11 folder and loading layout. I got a compilation error no resource found error, but I have layout there.

Thanks

Illidanek
  • 996
  • 1
  • 18
  • 32
mohan
  • 13,035
  • 29
  • 108
  • 178
  • Sorry you can't do it, check this existing SO Question: [Can the Android Layout folder contain subfolders?](http://stackoverflow.com/questions/4930398/can-the-android-layout-folder-contain-subfolders)? – Paresh Mayani Mar 09 '12 at 08:52

3 Answers3

1

There are various ways to switch your layouts. Here are the top two:

Suppose in your code, you are going to inflate R.layout.my_layout.

  • Switch directly by adding selectors to layouts

Implement layouts:

res/layout/my_layout.xml
res/layout-land/my_layout.xml
res/layout-w600dp/my_layout.xml
  • Switch indirectly by adding selectors to values

Implement layouts:

res/layout/my_layout_narrow.xml
res/layout/my_layout_wide.xml

Implement values:

res/values/layouts.xml
    <resources>
        <item name="my_layout" type="layout">@layout/my_layout_narrow</item>
    </resources>

res/values-land/layouts.xml
    <resources>
        <item name="my_layout" type="layout">@layout/my_layout_wide</item>
    </resources>

res/values-w400dp/layouts.xml
    <resources>
        <item name="my_layout" type="layout">@layout/my_layout_narrow</item>
    </resources>

res/values-w800dp/layouts.xml
    <resources>
        <item name="my_layout" type="layout">@layout/my_layout_wide</item>
    </resources>
Sparky
  • 8,437
  • 1
  • 29
  • 41
0
Use dp instead of dip and put the below lines in The Android Manifest.xml file above <application/> tag & put your all images in simply drawable folder .Doing all these changes your app support all screen sizes.`<supports-screens 
          android:smallScreens="true" 
          android:normalScreens="true"
          android:largeScreens="true" 
          android:anyDensity="true"  >
          </supports-screens>
Pradeep Sodhi
  • 2,135
  • 1
  • 19
  • 19
0

See the guide topic Supporting Multiple Screens > Declaring Tablet Layouts for Android 3.2. You can specify resource folders for available width and height or for smallest width. For instance, you might have

  • res/values-sw600dp in which you would define margin_top when the smallest screen dimension available to your app is at least 600dp
  • res/values-w1024dp in which you would define margin_top when the screen width available to the application is at least 1024dp

etc.

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521