6

I have different layout files for different screens size like

Folder Structure:

  • layout
  • layout-large
  • layout-small

    For emulators like HVGA and QVGA there is no problem, the respective layout.xml file being refereed. But the layout-large folder is ignored when I run the emulator of WVGA(480x854) , here it is referring the "layout" folder of the application. Please point me to the right direction which is right way to handle this situation.

    I tried using

layout-large-hdpi layout-large-mdpi layout-large-ldpi layout-normal-hdpi layout-normal-mdpi layout-normal-ldpi

And in the AndroidManifest.xml I specified

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

but no success

Alexander Farber
  • 21,519
  • 75
  • 241
  • 416
Vinayak Bevinakatti
  • 40,205
  • 25
  • 108
  • 139

3 Answers3

7

I think the Problem is that people always create a large screen by AVD Manager and it sets the default density to 240 which is not supported by /res/layout-large If you want to want to test /res/layout-large/any_layout.xml then you should see the density of your virtual device it should be set to 160 not 240 or 120

Blue Moon
  • 71
  • 2
  • Can you explain why density=160 for tablet? because I am facing problem – Ranjithkumar Aug 05 '15 at 12:44
  • @RanjithKumar check this image: https://developer.android.com/images/screens_support/screens-ranges.png from this doc: https://developer.android.com/guide/practices/screens_support.html#overview – LLL Apr 19 '17 at 19:29
4

Make sure the set up emulator's default size is "large" and not "xlarge".

For example if the emulator size is "xlarge", then the "layout-large" folder will be ignored and the default "layout" folder will be used, because it can't find a "layout-xlarge" folder.

This is easy to identify if your using Android Studio.

Wilhelm
  • 113
  • 6
  • How to identify this in Android Studio? I am facing the same problem - the layout is not used in Nexus 7 and 10 emulators - even though I have added **layout-large/activity_main.xml, layout-xlarge/activity_main.xml, layout-sw600dp/activity_main.xml, layout-sw720dp/activity_main.xml** and **layout-sw800dp/activity_main.xml**. – Alexander Farber Aug 10 '15 at 21:26
  • 1
    -> Open your AVD manager -> edit the AVD you're using -> At the hardware clone device, press "change" . You'll see that a size is displayed at the right. All the "phones" seem to be normal size, where if you choose from the "tablet" list the sizes would show large. – Wilhelm Aug 11 '15 at 21:36
1

Have you checked if your API Level is already supporting this? I had this issue as well. In my case I used following line in the manifest, which set the TargetSDK to 4 (1.6), where the support of those different layouts started.

<uses-sdk android:minSdkVersion="3"  android:targetSdkVersion="4" />

Links:
Screen Support

Wolkenjaeger
  • 908
  • 1
  • 10
  • 21
  • HI Wolkenjaeger I have specified no success. – Vinayak Bevinakatti Aug 09 '10 at 11:48
  • I am not sure if you understood the concept of small, medium, large and hdpi, mdpi, ldpi. Large is used for large screens like tablet devices and not high resolutions of mobile devices. Mobile devices are mostly medium screens. What you are looking for is for medium screens (like the Samsung Galaxy) with high resolutions. In this case you need to work with DPI. Layouts in android are automatically scaled to the correct size if you use DPI. However if you want to use different drawables, you must put them into drawables-hdpi -mdpi -ldpi I urge you to check out http://bit.ly/27nPxz again. – Wolkenjaeger Aug 13 '10 at 07:16