Where does android.max_aspect meta make difference?
Asked Answered
P

3

26

A recent blog explains that we must use

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

in <application> element of AndroidManifest.xml for optimal display on super widescreen devices, e.g. Samsung Galaxy S8.

To test this, I installed my app (no max_aspect, no resizeableActivity flags; targetSdkVersion=22, compileSdkVersion=24) on an Android 7.1.1. emulator with custom 2960x1440 resolution. All activities, including immersive, fill the screen with no margins as shown in the blog post.

I added explicit

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

and this also had no effect on the emulator.

So, the question: is this meta flag only checked on the real devices, or there is some configuration that I missed for my emulator?

Update: I tried to reach Neto Marin, the author of the cited blog post. I found a proud tweet ] about his contribution to the global Android Dev community, but could not get an answer from him.

Pincus answered 3/4, 2017 at 7:54 Comment(1)
Very similar findings to what @Alex found out. Any others with better updates.. ? :)Pedicel
P
4

Letterboxing happens on different devices, like Samsung S8, LG G6, Pixel 2 XL, and some others. It seems to be part of Android 8 and especially 8.1.

The official Android 8.1 compatibility definition includes the following paragraph:

[C-0-1] Device implementations with the Configuration.uiMode set as UI_MODE_TYPE_NORMAL MUST have an aspect ratio value between 1.3333 (4:3) and 1.86 (roughly 16:9), unless the app can be deemed as ready to be stretched longer by meeting one of the following conditions:

  • The app has declared that it supports a larger screen aspect ratio through the android.max_aspect metadata value.
  • The app declares it is resizeable via the android:resizeableActivity attribute.
  • The app is targeting API level 26 or higher and does not declare a android:MaxAspectRatio that would restrict the allowed aspect ratio.

Note that the first two attributes are application-level, while latter attribute belongs to Activity.

Some vendors allow the end-user to control this further. LG has "App Scaling" menu; Samsung lets you choose "full screen apps" on "Display" Settings.

Pincus answered 7/2, 2018 at 9:4 Comment(2)
Did you manage to reproduce the letterbox behavior on an emulator ?Martinemartineau
I also failed to get a letterbox using a normal emulator and a Genymotion VM. Is testing on a real "large AR" device the only known solution to this day?Martinemartineau
F
9

The android.max_aspect only makes difference if your android:resizeableActivity is not true. If your app's target API is 24 or higher android:resizeableActivity is set as true.

Note: You do not need to set a maximum aspect ratio if an activity's android:resizeableActivity attribute is set to true. If your app targets API level 24 or higher, this attribute defaults to true. For more information, see Configuring your app for multi-window mode.

Please refer to the documentation.

Fertilize answered 21/4, 2017 at 8:55 Comment(4)
Thanks, I have read the instructions, but I could not reproduce this behavior on emulator. I did not target API 24 and did not declare resizeable activity.Pincus
I was able to reproduce this on actual device Galaxy S8Enthusiasm
@YasithaChinthaka could you reproduce on your Galaxy S8 the behavior of not declaring max_aspect? CommonsWare states that in his experiment, this setting did never have any effect.Pincus
Does this mean that, after API 24, it is safe to leave this metadata in place, as it will be ignored (since resizeableActivity is true by default?). Or, will it still be consulted, restricting the app's ability to resize? In other words, for an APK that targets multiple Android versions, how does one best manage this meta-data attribute?Eri
P
4

Letterboxing happens on different devices, like Samsung S8, LG G6, Pixel 2 XL, and some others. It seems to be part of Android 8 and especially 8.1.

The official Android 8.1 compatibility definition includes the following paragraph:

[C-0-1] Device implementations with the Configuration.uiMode set as UI_MODE_TYPE_NORMAL MUST have an aspect ratio value between 1.3333 (4:3) and 1.86 (roughly 16:9), unless the app can be deemed as ready to be stretched longer by meeting one of the following conditions:

  • The app has declared that it supports a larger screen aspect ratio through the android.max_aspect metadata value.
  • The app declares it is resizeable via the android:resizeableActivity attribute.
  • The app is targeting API level 26 or higher and does not declare a android:MaxAspectRatio that would restrict the allowed aspect ratio.

Note that the first two attributes are application-level, while latter attribute belongs to Activity.

Some vendors allow the end-user to control this further. LG has "App Scaling" menu; Samsung lets you choose "full screen apps" on "Display" Settings.

Pincus answered 7/2, 2018 at 9:4 Comment(2)
Did you manage to reproduce the letterbox behavior on an emulator ?Martinemartineau
I also failed to get a letterbox using a normal emulator and a Genymotion VM. Is testing on a real "large AR" device the only known solution to this day?Martinemartineau
M
2

You have to set the emulator's aspect ratio as per your need.

Try these steps:

In Android Studio, open AVD Manager
Create Virtual Device
    New Hardware Profile
    Set name: "18:9 aspect ratio screen"
    Set resolution: 1080 x 2160
    Finish
Select "18:9 aspect ratio screen"
Next
Select system image Nougat (API Level 25)
Next
AVD Name: "API Level 25 Nougat 18x9 aspect ratio screen"
Finish

Then run on this emulator.

If you don't set a value, and android:resizeableActivity is not true, then the maximum aspect ratio defaults to 1.86 (roughly 16:9) and your app will not take advantage of the extra screen space.

You do not need to set a maximum aspect ratio if an activity's android:resizeableActivity attribute is set to true. If your app targets API level 24 or higher, this attribute defaults to true.

Marianelamariani answered 9/6, 2017 at 4:24 Comment(1)
I could not reproduce this behavior on emulator with exact same settings. I did not target API 24 and did not declare resizeable activity. Could you reproduce on this emulator the letterbox behavior of not declaring max_aspect? @CommonsWare states that in his experiment, this setting did never have any effect even on the real S8 device.Pincus

© 2022 - 2024 — McMap. All rights reserved.