How to support 18:9 aspect ratio in android apps?-ThrowExceptions

Exception or error:

The new Samsung galaxy S8 and LG G6 phones have aspect ratio of 18:9. This is different from the current aspect ratio of 16:9 that most android devices support. How to handle the new aspect ratio in existing android apps or newly created apps.

How to solve:

There are two ways to goes about it. First, you need to decide whether you want to support the new ratio in your app or not.

What happens if we choose NOT to support it?

Well, there will be some black space visible on the top and bottom of the screen while the app will be in the centre. This of course, will be the behaviour in the large aspect ratio phones (18:9). In standard aspect ratio phones (16:9) the app will work as is without any issue.

I see three main drawbacks to this:

1) The UI may look less appealing because of the black stripes on top and bottom.

2) You will lose out on taking advantage of the additional space available which could be utilized to your benefit.

3) You won’t be able to run your app in multi-window support. It is important to mention here that multi-window support is the primary reason for Google to push for the devices with newer aspect ratio. Because with a ratio of 2:1, the screen can be perfectly divided into two squares.

If you still decide for some reason not support it, then this is what you need to do:

In you app manifest,

set android:resizeableActivity to false.

By doing this the maximum aspect ratio is restored to 16:9 (approx.).

If you want your app to support the large aspect ratio, you need to do this:

In the <application> tag of your app manifest, add the following meta-data:

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

By doing so, you tell the android system that this app is designed to support maximum aspect ratio of 18.5:9 (approx. and that by the way is the aspect ratio of S8).

Leave a Reply

Your email address will not be published. Required fields are marked *