문제

I just had a basic question regarding the orientation. Currently my app just supports phones in portrait mode only. I just altered it to support tablets, but I am wondering how I can make it work for both orientations for tablet, keeping the phone orientation to portrait. Here is part of the code in my manifest for setting it to portrait:

<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>
도움이 되었습니까?

해결책

You can call setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); ine the onCreate method of your Activity if the device is a phone. To determine if the device is a phone or a tablet, you can have a look at this question.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top