1

I've been doing lots of research lately on optimizing my app for all screen sizes. I've created 9 of every layout in order to fit every size.

Don't worry about those other two layouts that are just in the layout directory, I will make 8 more of those later

(Android view) enter image description here

Some articles say to have more layouts, but of what? Am I missing something? Did I do this correctly?

I have some doubt about my screen sizes, as lots of people on the internet have different ways of targeting different devices, is this correct?

    <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>

Do I need to add more compatible screens? Because other documents have a lot more. Will my app show up on all devices, like tablets?

Is there anything I missed in order to be optimized for all devices, like tablets and phones? Must I create any new layouts or add more compatible screen permissions in the manifest?

1 Answers1

1

Use this

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

An application "supports" a given screen size if it resizes properly to fill the entire screen. Normal resizing applied by the system works well for most applications and you don't have to do any extra work to make your application work on screens larger than a handset device. However, it's often important that you optimize your application's UI for different screen sizes by providing alternative layout resources. For instance, you might want to modify the layout of an activity when it is on a tablet compared to when running on a handset device.

Please read official Document's about Declare Support for Tablet Screens & supports-screens . I hope it will helps you .

<compatible-screens>
<!-- all normal size screens -->
<screen android:screenSize="normal" android:screenDensity="mdpi" />
<screen android:screenSize="normal" android:screenDensity="hdpi" />
<screen android:screenSize="normal" android:screenDensity="xhdpi" />
<!-- all large size screens -->
<screen android:screenSize="large" android:screenDensity="mdpi" />
<screen android:screenSize="large" android:screenDensity="hdpi" />
<screen android:screenSize="large" android:screenDensity="xhdpi" />
<!-- all xlarge size screens -->
<screen android:screenSize="xlarge" android:screenDensity="mdpi" />
<screen android:screenSize="xlarge" android:screenDensity="hdpi" />
<screen android:screenSize="xlarge" android:screenDensity="xhdpi" />

Courtesy Goes to Optimizing Android manifest file for largest number of supported devices

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
  • 1
    Okay, am I missing anything in my layout folders? Am I supposed to only have 9? Will my app show up for tablets? –  Dec 16 '15 at 09:29
  • 1
    Yes, I read both the links. Still don't know if I have enough layout folders –  Dec 16 '15 at 09:36
  • `compatible-screens` Looks like perfect . – IntelliJ Amiya Dec 16 '15 at 09:38
  • 1
    No, thats now what I'm asking. My question is whether 9 layout folders is enough for all screen sizes. Look at my screen shot, will it work for all screen sizs? –  Dec 16 '15 at 09:41
  • @NullPointerException Okay now i understand . You can add some extra permission .Please check my edited answer . – IntelliJ Amiya Dec 16 '15 at 09:42
  • No, that is still not what Im asking. See my screen shot? It has 9 layouts, right? IS THAT ENOUGH? Do I need more layouts? Thanks –  Dec 16 '15 at 09:50
  • @NullPointerException No .You have enough Layouts – IntelliJ Amiya Dec 16 '15 at 09:51
  • Are you sure? A lot of places I see people with 10-20 layouts...So I'm good? –  Dec 16 '15 at 09:52
  • @NullPointerException . You can visit here http://stackoverflow.com/questions/8428096/design-layout-for-multiple-screens – IntelliJ Amiya Dec 16 '15 at 09:54
  • Okay, so I have been researching for an hour now, and I am confused. Do I include both the compatible screens and the supported screens? Or just one? –  Dec 16 '15 at 11:19
  • http://stackoverflow.com/questions/21850115/difference-between-supports-screens-and-compatible-screens-on-android I would prefer `compatible-screens` – IntelliJ Amiya Dec 16 '15 at 11:23
  • 1
    Okay thanks, so I'm actually only going to include the `supportsScreens`. So, you're absolutely sure that my app will show up on every android device made? (not counting ones under the min sdk) –  Dec 16 '15 at 11:48
  • I think that is incorrect because I tried this solution : before 7388 divices with your lines 6428 .... –  Jan 27 '16 at 14:25
  • @delive Okay , i will change my answer . What is `before 7388 divices with your lines 6428` ?? – IntelliJ Amiya Jan 27 '16 at 14:30
  • I used to have 7388 devices available with your lines I have eliminated approximately 950 , 7388 - 960 = 6428 devices available, I lose devices –  Jan 27 '16 at 14:38