如何设置机器人表演垂直方向? [英] How to set android show vertical orientation?

查看:91
本文介绍了如何设置机器人表演垂直方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从以下.xml文件,我将XML显示TabHost,但我在模拟器中运行它之后它同时显示两个方向。我想将它设置为只显示一个方向。我该怎么办?感谢你。

 < TabHost的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:ID =@机器人:ID / tabhost
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:方向=垂直>

    < RelativeLayout的
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =FILL_PARENT
        机器人:方向=垂直>

        <的FrameLayout机器人:ID =@机器人:ID / tabcontent
             机器人:layout_width =FILL_PARENT
             机器人:layout_height =FILL_PARENT
             机器人:layout_alignParentTop =真
             机器人:layout_above =@机器人:ID /标签/>
    < TabWidget机器人:ID =@机器人:ID /标签
             机器人:layout_width =FILL_PARENT
             机器人:layout_height =WRAP_CONTENT
             机器人:layout_alignParentBottom =真/>
    < / RelativeLayout的>
< / TabHost>
 

解决方案

在manifest.xml文件中加入这一行。

 <活动机器人:名称=活动
  机器人:screenOrientation =画像>
< /活性GT;
 

如果你只想横向然后更改为风景而不是人像

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:layout_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

这篇关于如何设置机器人表演垂直方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆