[英]Android - Lock phone to portrait but allow tablet to be both landscape and portrait
[英]Set portrait for phone but both portrait and landscape orientation for tablet
我只是有一個關於方向的基本問題。 目前,我的應用僅支持縱向模式的手機。 我只是對其進行了更改以支持平板電腦,但是我想知道如何使它同時適用於平板電腦的兩個方向,同時保持手機方向為縱向。 這是清單中將其設置為縱向的部分代碼:
<activity
android:name=".activities.SplashActivity"
android:clearTaskOnLaunch="true"
android:label="@string/app_name"
android:launchMode="singleTop"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@style/AppBaseTheme.NoActionBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:path="/msf1.0/public/mobilebootstrapper.aspx"/>
</intent-filter>
</activity>
<activity
android:name=".activities.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateUnchanged|adjustResize" >
</activity>
您可以調用setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
如果設備是電話,請在Activity中使用onCreate方法。 要確定設備是手機還是平板電腦,您可以看一下這個問題 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.