[英]Is it in the Gluon API to keep our app in Portrait Mode even if the user rotates their device in Landscape Mode?
在以縱向模式設置我的應用程序樣式后,我發現如果用戶操作他們的手機將應用程序調用到橫向模式,它的布局是不可接受的。 我可以稍后花時間重寫/重新測試縱向和橫向模式的用戶體驗,但暫時是我們讓我們的應用程序始終保持縱向模式的一種方式?
目前還沒有 API 或附加服務。 但是,您可以修改 AndroidManifest.xml 文件 (Android) 或 Default-Info.plist 文件 (iOS) 以強制單一方向,而不是現有的縱向和橫向方向。
安卓
請參閱https://docs.gluonhq.com/#_android_2以供參考。
AndroidManifest.xml 文件是為具有 gluonfx:package 目標的項目生成的,它位於 target/gluonfx/aarch64-android/gensrc/android。
將此文件復制到src/android
並進行所需的任何修改:
<?xml version='1.0'?>
<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='$your_package' android:versionCode='1' android:versionName='1.0'>
<application android:label='$your_label' android:icon="@mipmap/ic_launcher">
<activity android:name='com.gluonhq.helloandroid.MainActivity'
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="portrait">
<intent-filter>
<category android:name='android.intent.category.LAUNCHER'/>
<action android:name='android.intent.action.MAIN'/>
</intent-filter>
</activity>
</manifest>
<?xml version='1.0'?>
<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='$your_package' android:versionCode='1' android:versionName='1.0'>
<application android:label='$your_label' android:icon="@mipmap/ic_launcher">
<activity android:name='com.gluonhq.helloandroid.MainActivity'
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape">
<intent-filter>
<category android:name='android.intent.category.LAUNCHER'/>
<action android:name='android.intent.action.MAIN'/>
</intent-filter>
</activity>
</manifest>
然后再次運行gluonfx:package
,最終清單將包含更改。
IOS
請參閱https://docs.gluonhq.com/#_ios_2以供參考。
配置由鍵UISupportedInterfaceOrientations
和UISupportedInterfaceOrientations-ipad
。 默認值:
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
添加文件src/main/resources/META-INF/substrate/ios/Partial-Info.plist
並包含以下代碼:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
然后再次運行mvn gluonfx:link
,最終的 plist 將包含這些更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.