官方文檔:
- If your app targets Android 8.0 (API level 26) or higher, it fills the entire screen, according to its layout.
- If your app targets Android 7.1 (API level 25) or lower, the system limits the size of the app's interface to a window with an aspect ratio of 16:9 (approximately 1.86). If the app runs on a device with a larger screen aspect ratio, the app appears in a 16:9 letterbox that leaves part of the screen unused.
大致翻譯:
- 如果應(yīng)用針對(duì)的是Android 8.0(API級(jí)別26)或更高版本痢站,則會(huì)根據(jù)其布局填充整個(gè)屏幕。
- 如果您的應(yīng)用面向Android 7.1(API級(jí)別25)或更低挪丢,系統(tǒng)會(huì)將應(yīng)用界面的大小限制為縱橫比為16:9(約1.86)的窗口。如果應(yīng)用程序在較大屏幕縱橫比的設(shè)備上運(yùn)行,則該應(yīng)用程序?qū)@示在16:9區(qū)域中渐夸,使得部分屏幕未使用箍镜。
當(dāng)應(yīng)用未適配全面屏?xí)r源祈,就會(huì)出現(xiàn)問(wèn)題。
因此色迂,谷歌官方建議:
If your app layout cannot adapt to arbitrarily large aspect ratios, you can explicitly enforce letterboxing on all Android OS levels by setting a maximum aspect ratio. We recommend a ratio of 2.4 (12:5).
如果app布局無(wú)法適應(yīng)任意大的縱橫比香缺,則可以通過(guò)設(shè)置最大縱橫比來(lái)強(qiáng)制顯示。建議比率為2.4(12:5)歇僧。
Android 8.0 (API level 26) 或更高
<!-- Render on full screen up to screen aspect ratio of 2.4 -->
<!-- Use a letterbox on screens larger than 2.4 -->
<activity android:maxAspectRatio="2.4">
...
</activity>
Android 7.1及以下
<!-- Render on full screen up to screen aspect ratio of 2.4 -->
<!-- Use a letterbox on screens larger than 2.4 -->
<meta-data android:name="android.max_aspect" android:value="2.4" />
Tips : 如果設(shè)置最大縱橫比图张,請(qǐng)不要忘記也設(shè)置 android:resizeableActivity = false。否則诈悍,最大縱橫比無(wú)效祸轮。(resizeableActivity默認(rèn)為false,該屬性也會(huì)支持分屏顯示)
個(gè)人總結(jié)
最好的做法就是將應(yīng)用升級(jí)到最新版本(目前是28)侥钳,這樣就能自動(dòng)適配全屏适袜;但是并不意味著UI能夠正常顯示,UI適配仍是開(kāi)發(fā)和設(shè)計(jì)需要完善的問(wèn)題舷夺。
參考鏈接:
https://developer.android.com/guide/practices/screens_support
https://developer.huawei.com/consumer/cn/devservice/doc/50111