所謂全面屏手機,就是屏幕縱橫比大于1.86的設備。例如:
舉個例子.png
官方文檔:
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.
大致翻譯:
如果應用針對的是Android 8.0(API級別26)或更高版本,則會根據其布局填充整個屏幕。
如果您的應用面向Android 7.1(API級別25)或更低,系統會將應用界面的大小限制為縱橫比為16:9(約1.86)的窗口。如果應用程序在較大屏幕縱橫比的設備上運行,則該應用程序將顯示在16:9區域中,使得部分屏幕未使用。
當應用未適配全面屏時,就會出現問題。
因此,谷歌官方建議:
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布局無法適應任意大的縱橫比,則可以通過設置最大縱橫比來強制顯示。建議比率為2.4(12:5)。
Android 8.0 (API level 26) 或更高
...
Android 7.1及以下
Tips : 如果設置最大縱橫比,請不要忘記也設置 android:resizeableActivity = false。否則,最大縱橫比無效。(resizeableActivity默認為false,該屬性也會支持分屏顯示)
個人總結
最好的做法就是將應用升級到最新版本(目前是28),這樣就能自動適配全屏;但是并不意味著UI能夠正常顯示,UI適配仍是開發和設計需要完善的問題。