Qt-Android应用程序中的横向模式

问题描述 投票:1回答:2

我创建了一个Qt / QML应用程序并将应用程序移植到Android。现在我可以在Android设备上运行该应用程序了。我想将方向模式修复为横向。

我手动编辑了AndroidManifest.xml并将android:screenOrientation="unspecified"设置为android:screenOrientation="sensorLandscape"

<activity
  android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation"
  android:name="org.qtproject.qt5.android.bindings.QtActivity"
  android:label="Engage"
  android:screenOrientation="sensorLandscape"
  android:launchMode="singleTop">

每次部署项目时,清单都会被覆盖并重置为android:screenOrientation="unspecified"

android qt qml orientation
2个回答
2
投票

Qt Forum上,建议采用以下解决方案:

只需转到项目,运行,单击详细信息并创建androidmanifest.xml,选择一个目录。之后,如果它没有自动发生并编辑它,则将其添加到您的项目中。第4行应如下所示:

@<activity android:screenOrientation="unspecified" android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="@string/app_name">@ 

只需将“unspecified”更改为“sensorLandscape”并保存即可。

每次部署时都不会覆盖它。


2
投票

我得到了一个解决方案。

在项目文件夹中添加一个文件夹。我把它命名为'android-sources'。从android-build复制你的AndroidManifest.xml并粘贴到'android-sources'文件夹。打开.pro文件并添加以下内容

OTHER_FILES += \
    android-sources/AndroidManifest.xml
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android-sources

然后打开AndroidManifest.xml

改变方向

android:screenOrientation="sensorLandscape"
© www.soinside.com 2019 - 2024. All rights reserved.