关于android布局中的横竖屏切换的问题
各位大虾,你们好
想请教你们一个问题,我的xml布局在模拟器中运行的时候出现一个问题,就是切换为横屏的时候,处在竖屏下方的控件就无法显示了!这是什么问题,该怎么解决呢?谢谢啦~~
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/widget54"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
style="@style/Theme.home"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<TextView
android:id="@+id/widget30"
android:text="welcome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="50sp"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:layout_marginTop="50px"
>
</TextView>
<Button
android:id="@+id/widget31"
android:layout_width="175px"
android:layout_height="wrap_content"
android:text="data"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:layout_below="@id/widget30"
android:layout_marginTop="40px"
>
</Button>
<Button
android:id="@+id/widget32"
android:layout_width="175px"
android:layout_height="wrap_content"
android:text="data"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:layout_below="@id/widget31"
android:layout_marginTop="20px"
>
</Button>
<Button
android:id="@+id/widget33"
android:layout_width="175px"
android:layout_height="wrap_content"
android:text="@string/exit"
android:textStyle="bold"
android:layout_centerHorizontal="true"
android:layout_below="@id/widget32"
android:layout_marginTop="20px"
>
</Button>
<TextView
android:id="@+id/widget34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="company"
android:textColor="#ff666666"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
>
</TextView>
</RelativeLayout>
[解决办法]
你的Androidmanifest.xml
使用该Activity的LanchMode,改成默认的standard模式
[解决办法]
使用scrollview吧
[解决办法]
重新写一个同名的横屏的布局文件 放在layout-land下面。
[解决办法]
你加一个ScrollView滚动条不行吗?
[解决办法]
[解决办法]
为是么要把width都定死了,用比重属性吧,按比例来划分就不会这样了
[解决办法]
android:layout_marginTop="50px"
太大太占空间了,在横屏时尤其明显,本来横屏的高度就有限。
[解决办法]
[解决办法]
用的是绝对坐标,而且单位是px的,这些都不是好习惯。
------解决方案--------------------
横竖屏幕大小不一样,按照你定义的大小肯定看不见了。你最好再定义一个针对竖屏的xml,放到layout-land文件夹下面。