Support for maximum screen format without hardcoded ratio?

Basically, my app is independent of the aspect ratio of the screen (as it is for an Android app). It is now recommended to manually add

<meta-data android:name="android.max_aspect" android:value="ratio_float" />

      

in the manifest due to the trend of smartphone screens with aspect ratios higher than the default ratio of 1.86. My question is that instead of setting a hardcoded ratio like 2.1, is there a better way to tell Android that I don't care what the maximum compression ratio is?

If not, can I set an arbitrarily high value such as 3.1 or even 5.1? Is it safe? I'm not talking about exotic weird screen sizes, but the main screens of the future and best practice for that in the future. Thanks you

+3


source to share


2 answers


David's answer is correct if we want to support high aspect ratio screens on API <24 (up to Nougat). However, the documentation says it android:resizeableActivity

defaults to API 24 and up. This means the app will be automatically free form in the future (correct me if I'm wrong). Considering the Galaxy S8 already ships with Nougat out of the box, I'd say there's no need to worry if your app is okay with freeform styling.



EDIT: If your targetSdkVersion is <24 then you should use David's solution because freeform will not automatically load for phones with Nougat (or higher) installed.

0


source


As you can see on the Android Developers Blog , they also hint at resizableActivity

.

Note: if you haven't set a value and android: resizeableActivity is not true, then the default maximum aspect ratio is 1.86 (roughly 16: 9) and your app will not use the extra screen space.

So, you have to add android:resizeableActivity="true"

to your activity or application. The documentation also states



If this attribute is set to true, the activity can be launched in split-screen and freeform modes.

And it looks like freeform mode is what you care about.

+2


source







All Articles