How to support extra large screens in Android?

2019-04-08 13:59发布

问题:

According to this doc page, Android 2.3 supports extra large screen sizes (xlarge), and you can declare that your apps supports this size by adding android:xlargeScreens="true" in the <supports-screens> tag in the Manifest file.

But, since my app is targeted for a minimum SDK version of Android 2.1, compilation fails complaining about unknown attribute.

I don't want to use the new SDK because I won't get warnings if I accidentally use 2.3 specific features.

Is there a way out?

回答1:

You'll have to use the 2.3 SDK because that attribute simply is not known in lower SDKs. However, what you can do is set your target SDK to be 2.1.



回答2:

It looks like that element is only supported for Android 2.3. As per the docs here:

Note: Android 2.3 (API Level 9) introduced a new attribute for the element: xlargeScreens

I believe that means that you can't, in fact, use that attribute unless you're compiling for Android 2.3.



回答3:

This worked for me like a charm.

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

Refer here for more assistance.