andorid orientation setting

Related API:

      ActivityInfo.java

      Activity.java     

       // switch the screen orientation together

       // portrait: 竖向, default orientation in manifest.xml; landscape: 横向

        if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {

            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        }

        else if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {

            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        }

       manifest.xml:

       <activity

            android:name=".activity.ConfigActivity"

            android:screenOrientation="portrait" >

        </activity>

猜你喜欢

转载自sunzeping.iteye.com/blog/1855236