如何在Android应用中支持18:9的宽高比? [英] How to support 18:9 aspect ratio in android apps?

查看:391
本文介绍了如何在Android应用中支持18:9的宽高比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的三星银河S8和LG G6手机的纵横比为18:9.这与大多数android设备支持的当前16:9宽高比不同.如何在现有的android应用程序或新创建的应用程序中处理新的宽高比.

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.

推荐答案

有两种解决方法.首先,您需要确定是否要在应用中支持新比例.

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.

如果我们选择不支持它会怎样?

好吧,当应用程序位于中间时,屏幕的顶部和底部会出现一些黑色空间.当然,这将是大长宽比手机(18:9)中的行为.在标准长宽比(16:9)的手机中,该应用将按原样运行,没有任何问题.

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)由于顶部和底部的黑色条纹,UI可能看起来不那么吸引人.

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

2)您将无法利用可能为您带来好处的额外可用空间.

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

3)您将无法在多窗口支持下运行您的应用.在此必须提及的重要一点是,多窗口支持是Google推出具有更高纵横比的设备的主要原因.因为以2:1的比例,屏幕可以完美地分成两个正方形.

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:

在您的应用清单中,

android:resizeableActivity设置为false.

这样做,最大纵横比将恢复为16:9(大约).

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

如果您希望您的应用支持宽高比,则需要执行以下操作:

在您的 app清单的<application>标签中,添加以下元数据:

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

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

这样做,您告诉android系统,此应用旨在支持最大18.5:9的纵横比(大约是S8的纵横比).

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).

这篇关于如何在Android应用中支持18:9的宽高比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆