我找到了解决方案,无需使用任何插件。我们可以在 config.xml 中进行配置,以便在构建时修改 AndroidManifest.xml。
将以下内容放入 config.xml
<edit-config file="AndroidManifest.xml" target="/manifest/application/activity[@android:name='MainActivity']" mode="merge">
<activity android:name="MainActivity" android:screenOrientation="userLandscape" />
</edit-config>
同时在 config.xml 的 <widget> 标签中添加以下内容
xmlns:android="schemas.android.com/apk/res/android"
以下是screenOrientation 字段的可能值
screenOrientation (attr) enum [behind=3, fullSensor=10, fullUser=13,
landscape=0, locked=14, nosensor=5, portrait=1, reverseLandscape=8,
reversePortrait=9, sensor=4, sensorLandscape=6, sensorPortrait=7,
unspecified=4294967295, user=2, userLandscape=11, userPortrait=12]