我已经为一个活动创建了一个布局。布局包含一些图像按钮和文本视图。问题是,当我将设备的方向设置为纵向时,它工作正常,但是当我将方向更改为横向时,布局会产生意想不到的结果。
这是我的布局文件:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:padding="50dp" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/settings_imageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:src="@android:drawable/bottom_bar" />
<TextView
android:id="@+id/settings_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:text="@string/my_settings"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/myProgramming_imageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/settings_imageView"
android:layout_alignParentLeft="true"
android:src="@android:drawable/bottom_bar" />
<TextView
android:id="@+id/myProgramming_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/myProgramming_imageView"
android:layout_centerHorizontal="true"
android:layout_marginBottom="14dp"
android:text="@string/my_programming"
android:textAppearance="?android:attr/textAppearanceMedium" />
<ImageView
android:id="@+id/library_imageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/myProgramming_imageView"
android:layout_alignParentLeft="true"
android:src="@android:drawable/bottom_bar" />
<TextView
android:id="@+id/library_textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/library_imageView"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
android:text="@string/library"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</ScrollView>
这是设备上纵向模式的输出,这是纵向和横向模式下的预期输出:
这是设备上横向 模式的输出,这是出乎意料的:
我希望布局在纵向和横向模式下看起来相似。