[英]How to set android:screenOrientation=“portrait” for Camera
[英]Set screenOrientation to "portrait" in release build only
在**AndroidManifest.xml**
我有一個**Activity**
縱向模式:
<activity
android:name=".home.MainActivity"
android:screenOrientation="portrait">
我發現在開發過程中臨時刪除android:screenOrientation="portrait"
行以便更早地捕獲與保存實例狀態相關的錯誤很有用。
是否可以僅在發布版本中將屏幕方向設置為縱向並且對於調試版本保持默認行為?
將此添加到您的活動中,
if (!BuildConfig.DEBUG) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
您可以在調試版本中覆蓋部分 AndroidManifest。 在src/debug
創建另一個 AndroidManifest.xml,並告訴合並工具為您的活動替換 screenOrientation 屬性:
<activity
android:name=".home.MainActivity"
tools:replace="android:screenOrientation"
android:screenOrientation="unspecified"/>
有關更多信息,請參閱 文檔。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.