Android:手机在横向模式下屏幕在底部裁剪

时间:2015-02-16 06:20:59

标签: android screen

我使用eclipse为Android创建了屏幕。屏幕在纵向模式下正确显示,但当我们移动旋转到RelativeLayout中的横向屏幕区域时裁剪。我通过删除RelativeLayout尝试了同样的方法,但都是徒劳的。

当手机处于横向模式时,

屏幕在底部被裁剪

*<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:scrollbars="vertical"
    >
    <TextView
        android:id="@+id/txtspace1"
        android:layout_width="match_parent"
        android:layout_height="16dp"
        android:layout_gravity="center"
        android:text="" />

    <ImageView
        android:id="@+id/launcher"
        android:layout_width="fill_parent"
        android:layout_height="100dp"
        android:layout_gravity="center"
        android:contentDescription="@string/image"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/txtApp_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/app_name"
        android:textAppearance="?android:textAppearanceMedium"
        />
    <TextView
        android:id="@+id/txt1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:gravity="center"
        android:text="@string/txt1"
        android:textAppearance="?android:textAppearanceMedium" 
        />
    <TextView
        android:id="@+id/txt2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/txt2"
        android:textAppearance="?android:textAppearanceMedium"
        />
    <TextView
        android:id="@+id/txtspace2"
        android:layout_width="fill_parent"
        android:layout_height="16dp"
        android:gravity="center"
        android:text=""
        android:textAppearance="?android:textAppearanceMedium" />
    <TextView
        android:id="@+id/txt3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/txt3"
        android:textAppearance="?android:textAppearanceSmall" 
        />
    <TextView
        android:id="@+id/txtspace3"
        android:layout_width="fill_parent"
        android:layout_height="16dp"
        android:gravity="center"
        android:text="" />
    <RelativeLayout
        android:id="@+id/RelativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="fill"

        >
      <Button
          android:id="@+id/txt5"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_marginBottom="5dp"
          android:text="@string/txt5"
          android:textAppearance="?android:textAppearanceSmall" />
       <TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/txt5"
          android:layout_alignParentLeft="true"
          android:text="@string/txt6"
          android:paddingBottom="5dp"
          android:paddingLeft="5dp"
          android:paddingRight="5dp"
          android:textAppearance="?android:attr/textAppearanceSmall" />
    </RelativeLayout>
</LinearLayout>*

1 个答案:

答案 0 :(得分:0)

将整个linearlayout放在scrollview中。这将解决它。

<?xml version="1.0" encoding="utf-8"?>
 <ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/scrollview_category"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true" >
<LinearLayout 
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    >
    <TextView
        android:id="@+id/txtspace1"
        android:layout_width="match_parent"
        android:layout_height="16dp"
        android:layout_gravity="center"
        android:text="" />

    <ImageView
        android:id="@+id/launcher"
        android:layout_width="fill_parent"
        android:layout_height="100dp"
        android:layout_gravity="center"
        android:contentDescription="@string/image"
        android:src="@drawable/ic_launcher" />

    <TextView
        android:id="@+id/txtApp_name"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/app_name"
        android:textAppearance="?android:textAppearanceMedium"
        />
    <TextView
        android:id="@+id/txt1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        android:gravity="center"
        android:text="@string/txt1"
        android:textAppearance="?android:textAppearanceMedium" 
        />
    <TextView
        android:id="@+id/txt2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/txt2"
        android:textAppearance="?android:textAppearanceMedium"
        />
    <TextView
        android:id="@+id/txtspace2"
        android:layout_width="fill_parent"
        android:layout_height="16dp"
        android:gravity="center"
        android:text=""
        android:textAppearance="?android:textAppearanceMedium" />
    <TextView
        android:id="@+id/txt3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:text="@string/txt3"
        android:textAppearance="?android:textAppearanceSmall" 
        />
    <TextView
        android:id="@+id/txtspace3"
        android:layout_width="fill_parent"
        android:layout_height="16dp"
        android:gravity="center"
        android:text="" />
    <RelativeLayout
        android:id="@+id/RelativeLayout1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="fill"

        >
      <Button
          android:id="@+id/txt5"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:layout_marginBottom="5dp"
          android:text="@string/txt5"
          android:textAppearance="?android:textAppearanceSmall" />
       <TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/txt5"
          android:layout_alignParentLeft="true"
          android:text="@string/txt6"
          android:paddingBottom="5dp"
          android:paddingLeft="5dp"
          android:paddingRight="5dp"
          android:textAppearance="?android:attr/textAppearanceSmall" />
    </RelativeLayout>
</LinearLayout>
</ScrollView>