cordova安卓全面屏适配

版权声明:独学而无友,则孤陋寡闻。q群582951247 https://blog.csdn.net/mp624183768/article/details/83573291

之前项目中打包的apk安装到全面屏手机后,发现在应用下方出现了一大块黑色区域(如:小米8),只有在系统中设置适配全面屏才能让应用在全面屏手机中显示正常,但是这种方式并不友好,而且有些手机厂商可能也没有这种设置,所以还是需要我们再打包的时候就做一些相应的处理。

处理方式也比较简单,打开安卓工程下的AndroidManifest.xml,在

application 节点下
        <activity
            android:name=".MainActivity"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
            android:exported="true"
            android:label="@string/activity_name"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.DeviceDefault.NoActionBar"
            android:windowSoftInputMode="adjustPan">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>

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

其中添加:

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

如图:

image.png

再编译后重新打包,就可以适配全面屏了


 

猜你喜欢

转载自blog.csdn.net/mp624183768/article/details/83573291