How to set android show vertical orientation?

前端 未结 3 1554
粉色の甜心
粉色の甜心 2020-12-06 12:39

From following .xml file I set xml to show TabHost but after i run it on emulator it show both both orientation. i want to set it to show only one orientation. How do i do?

相关标签:
3条回答
  • 2020-12-06 12:54

    add this line in your manifest.xml file.

    <activity android:name=".activity"
      android:screenOrientation="portrait">
    </activity>
    

    if you want only landscape orientation then change to landscape instead of portrait

    0 讨论(0)
  • 2020-12-06 12:55

    In the AndroidMainfeast.xml file you will see

    <activity
    android:name=".MainActivity"
    android:theme="@style/AppTheme.NoActionBar">
    </activity>
    

    so Add after .MainActivity

    android:screenOrientation="portrait"
    android:configChanges="keyboardHidden|orientation|screenSize"
    

    android:configChanges="" help us to prevent onpause() and OnResume() method when we made rotation.

    0 讨论(0)
  • 2020-12-06 13:12

    Set in this android:screenOrientation="portrait" in your activity in manifest .

    0 讨论(0)
提交回复
热议问题