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? THanks you.
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="fill_parent"
android:la开发者_如何学JAVAyout_height="fill_parent"
android:orientation="vertical">
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_above="@android:id/tabs" />
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</TabHost>
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
Set in this android:screenOrientation="portrait"
in your activity in manifest .
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.
精彩评论