1

Hello I am trying to target only Android phones only. I got to know compatible-screen tag can help me to achieve this. I see there is another tag support-screen.

Is there any use of it in Android ? What it does ?

Thanks in advance.

N Sharma
  • 33,489
  • 95
  • 256
  • 444
  • 1
    http://developer.android.com/guide/topics/manifest/supports-screens-element.html http://developer.android.com/guide/practices/screens-distribution.html#FilteringHansetApps The latter of those links is to another section on the same page that I linked to in my previous answer to you. – CommonsWare Aug 10 '14 at 16:39
  • @CommonsWare I would appreciate if you answer here so that it would be great for future readers also – N Sharma Aug 10 '14 at 16:40

1 Answers1

1

Quoting the Developers-Site:: Use these lines below in your manifest

<manifest ... >
    <compatible-screens>
        <!-- all small size screens -->
        <screen android:screenSize="small" android:screenDensity="ldpi" />
        <screen android:screenSize="small" android:screenDensity="mdpi" />
        <screen android:screenSize="small" android:screenDensity="hdpi" />
        <screen android:screenSize="small" android:screenDensity="xhdpi" />
        <!-- all normal size screens -->
        <screen android:screenSize="normal" android:screenDensity="ldpi" />
        <screen android:screenSize="normal" android:screenDensity="mdpi" />
        <screen android:screenSize="normal" android:screenDensity="hdpi" />
        <screen android:screenSize="normal" android:screenDensity="xhdpi" />
    </compatible-screens>
    ...
    <application ... >
        ...
    <application>
</manifest>

Using these lines will make your app to work only on handsets !

Hope this Clears your Question !


{EDIT} - Reference

 /res/layout/layout.xml         // Default layout
 /res/layout-small/layout.xml   // Small screens
 /res/layout-large/layout.xml   // Large screens
 /res/layout-xlarge/layout.xml  // Ex

You can go even further and make also different layouts for portrait and landscape views by specyfing another keyword in directory's name:

 /res/layout-small-land/layout.xml      // Small screens, landscape view
 /res/layout-small-portrait/layout.xml  // Small screens, portrait view

Remember that tags order is important, so you can't write layout-portrait-small.

And in last add this code to your manifest file:

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

whenever you run application in any device according to that screen size that layout called

Community
  • 1
  • 1
Devrath
  • 42,072
  • 54
  • 195
  • 297
  • I didn't ask that which you answered :). I asked I see there is another tag support-screen. Is there any use of it in Android ? What it does ? – N Sharma Aug 10 '14 at 17:21
  • Check this link ......... http://stackoverflow.com/q/17463634/1083093 .... and here http://developer.android.com/training/multiscreen/index.html – Devrath Aug 10 '14 at 17:25
  • Thanks can you please update your answer so that I will accept it. My question is what it is the use of `support-screen` do even we have already `compatible-screen` tag – N Sharma Aug 13 '14 at 08:32