Android Tutorial Update your app to take advantage of the larger aspect ratio on new Android flagship devices

To deliver more engaging viewing experiences to their users, many Android OEMs are experimenting with new, super widescreen smartphones. Samsung has just announced a new flagship device, the Samsung Galaxy S8, featuring a new display format with an aspect ratio of 18.5:9. At the Mobile World Congress earlier this year, LG also launched their new flagship device, the LG G6, with an expanded screen aspect ratio of 18:9.

image00.png


In order to take full advantage of the larger display formats on these devices, you should consider increasing your app's maximum supported aspect ratio. To do so, simply declare an android.max_aspect <meta-data> element in the app's <application> element:

B4X:
AddActivityText(main,
<meta-data android:name="android.max_aspect"
    android:value="ratio_float"/>)

Where ratio_float is the maximum aspect ratio your app can support, expressed as (longer dimension / shorter dimension) in decimal form.

We recommend that you design your app to support aspect ratios of 2.1 or higher. For this, you would add the following to the <application> element:

B4X:
AddActivityText(main,
<meta-data android:name="android.max_aspect"
    android:value="2.1"/>)

Note: 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.

As more super widescreen Android devices, like the Samsung Galaxy S8 and the LG G6, become available, you'll have more opportunities to display more content and create more engaging experiences with your app.
 
Last edited:

sorex

Expert
Licensed User
Longtime User
I don't get it. we have dozens of different resolutions and there we didn't have to do anything to make it full screen.

What makes this case require this extra step? is it like a second screenmode that you can enable?
 

Multiverse app

Active Member
Licensed User
Longtime User
we have dozens of different resolutions and there we didn't have to do anything to make it full screen.
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.
 

Dave O

Well-Known Member
Licensed User
Longtime User
So, is it easiest for most apps (those that don't have special screen-size needs) to set android:resizeableActivity to true, so they don't need to muck around with aspect ratios at all?
 

Pendrush

Well-Known Member
Licensed User
Longtime User
I have done all of this, with support for split screen by adding these two lines in manifest:
B4X:
SetApplicationAttribute(android:resizeableActivity, "true")
AddApplicationText(<meta-data android:name="android.max_aspect" android:value="10"/>)
10 value is to be sure to cover all future possible and impossible resolutions for example 90:9 (10:1).
NOTE: All my activities use anchors and designer script, so I don't need to think what resolution is on device.

EDIT:
If you use AdMob and smart banner, use calculation from link below, for banner size and banner will resize itself in split screen and ad will be shown:
https://www.b4x.com/android/forum/t...ith-firebase-backend.67710/page-3#post-457009
 
Last edited:

ilan

Expert
Licensed User
Longtime User
hi

i am getting an error when i add this to my manifest:

B4X:
SetApplicationAttribute(android:resizeableActivity, "true")
AddApplicationText(<meta-data android:name="android.max_aspect" android:value="10"/>)

B4A version: 7.01
Parsing code. (0.06s)
Compiling code. (0.17s)
Compiling layouts code. (0.03s)
Organizing libraries. (0.00s)
Generating R file. Error
AndroidManifest.xml:16: error: No resource identifier found for attribute 'resizeableActivity' in package 'android'
 

ilan

Expert
Licensed User
Longtime User
Last edited:
Top