在AndroidManifest的application里面設置resizeableActivity的屬性為true
<application
android:name=".CompleteCarSellApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:resizeableActivity="true">
對於Android 8(API級別26)以上,只需要布局時填充屏幕即可
對於Android 7.1(API級別25)以下,系統默認將應用顯示的大小限制為一個長寬比為16:9(約1.86)的窗口。如果這個應用在屏幕比大的手機上運行,會出現一部分屏幕是黑屏的情況,這時我們就需要聲明最大屏幕縱橫比了。
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:resizeableActivity="false"
android:theme="@style/AppTheme">
<meta-data
android:name="android.max_aspect"
android:value="2.4" />
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
