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

Discussion in 'Tutorials & Examples' started by Multiverse app, Mar 31, 2017.

  1. Multiverse app

    Multiverse app Active Member Licensed User

    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.

    [​IMG]

    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:

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

    Code:
    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: Mar 31, 2017
    moster67, KZero, MarcoRome and 2 others like this.
  2. Erel

    Erel Administrator Staff Member Licensed User

    It should be AddApplicationText instead of AddActivityText.
     
    Multiverse app likes this.
  3. sorex

    sorex Expert Licensed 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?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. Multiverse app

    Multiverse app Active Member Licensed User

    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.
     
  6. Dave O

    Dave O Active Member Licensed 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?
     
  7. LucaMs

    LucaMs Expert Licensed User

    ... if the manufacturers would use a single ratio (16:9, the same as TV). But they love to be... original!

    What if tomorrow Samsung would produce a 20:9 TV?

    I can not write what I think of them!
     
  8. Pendrush

    Pendrush Well-Known Member Licensed User

    I have done all of this, with support for split screen by adding these two lines in manifest:
    Code:
    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: Mar 31, 2017
    ilan, yiankos1, MarcoRome and 2 others like this.
  9. ilan

    ilan Expert Licensed User

    hi

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

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

    Erel Administrator Staff Member Licensed User

    You need to use a newer version of android.jar (Tools - Configure Paths).
     
    ilan likes this.
  11. ilan

    ilan Expert Licensed User

    thanx a lot that worked. i installed SDK 25 and changed the android.jar path.
     
  12. ilan

    ilan Expert Licensed User

    Last edited: Jul 2, 2017
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice