我有這些cardView裏面的圖片-1(https://imgur.com/a/aO5Ss)中顯示的ScrollView,其中設備是垂直的,一切都如設想的那樣,但是當設備水平傾斜時,第四行中的第二行get cutoff如圖所示image-2(https://imgur.com/9ykZew4)。請幫助解釋爲什麼會發生這種情況,以及如何解決這個問題。 (注意 - 在第四卡有其通過從colmn_row.xml TextView的膨脹的列表視圖)ScrollView裏面的卡片
activity_main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp"
android:background="#ddd"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/activity_main"
tools:context=".MainActivity">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v7.widget.CardView
android:id="@+id/num_stu"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="10dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@mipmap/ic_launcher_round" />
<TextView
android:id="@+id/cardview_list_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image"
android:paddingBottom="5dp"
android:text="Students"
android:textSize="24sp" />
<TextView
android:id="@+id/num_boys"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title"
android:layout_toRightOf="@+id/cardview_image"
android:textColor="#8b8b8b" />
<TextView
android:id="@+id/num_girls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title"
android:layout_toRightOf="@+id/num_boys"
android:textColor="#8b8b8b" />
<TextView
android:id="@+id/total_stu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/num_girls"
android:layout_toRightOf="@+id/cardview_image"
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/num_teachers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/num_stu"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="8dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@mipmap/ic_launcher_round" />
<TextView
android:id="@+id/cardview_list_title1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image1"
android:paddingBottom="5dp"
android:text="Staff"
android:textSize="24sp" />
<TextView
android:id="@+id/numTeaching"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title1"
android:layout_toRightOf="@+id/cardview_image1"
android:textColor="#8b8b8b" />
<TextView
android:id="@+id/non_num_Teaching"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/numTeaching"
android:layout_toRightOf="@+id/cardview_image1"
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="@+id/attendance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:elevation="5dp"
android:padding="16dp">
<ImageView
android:id="@+id/cardview_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginRight="18dp"
android:src="@mipmap/ic_launcher_round" />
<TextView
android:id="@+id/cardview_list_title2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/cardview_image2"
android:paddingBottom="5dp"
android:text="Attendance"
android:textSize="24sp" />
<TextView
android:id="@+id/stuatten"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/cardview_list_title2"
android:layout_toRightOf="@+id/cardview_image2"
android:textColor="#8b8b8b"/>
<TextView
android:id="@+id/staffatten"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/stuatten"
android:layout_toRightOf="@+id/cardview_image2"
android:textColor="#8b8b8b" />
</RelativeLayout>
</android.support.v7.widget.CardView>
<!-- Fourth Card -->
<android.support.v7.widget.CardView
android:id="@+id/notice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:elevation="8dp"
android:padding="16dp">
<TextView
android:id="@+id/title"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:paddingBottom="5dp"
android:textSize="19sp"
android:textStyle="bold"
android:text="ID"/>
<TextView
android:id="@+id/title1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:paddingBottom="5dp"
android:textSize="19sp"
android:textStyle="bold"
android:layout_marginLeft="115dp"
android:layout_toRightOf="@+id/title"
android:text="Title"/>
<TextView
android:id="@+id/title2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:paddingBottom="5dp"
android:textSize="19sp"
android:textStyle="bold"
android:layout_toRightOf="@+id/title1"
android:layout_marginLeft="90dp"
android:text="Date From"/>
<TextView
android:id="@+id/title3"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:paddingBottom="5dp"
android:textSize="19sp"
android:textStyle="bold"
android:text="Date To"/>
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/title" >
</ListView>
</RelativeLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
</ScrollView>
</LinearLayout>
colmn_row.xml -
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/name"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:textStyle="bold"
android:textSize="17sp"/>
<TextView
android:id="@+id/gender"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="17sp"/>
<TextView
android:id="@+id/age"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:textSize="17sp"/>
<TextView
android:id="@+id/status"
android:layout_height="wrap_content"
android:layout_width="0dp"
android:layout_alignParentLeft="true"
android:layout_weight="1"
android:textSize="17sp"/>
</LinearLayout>
有你聲明佈局土地文件夾中的佈局? – Vij
@Vij我不熟悉前端開發,能否請您解釋一下佈局土地是什麼以及它的用途。謝謝 –
複製佈局文件在layout-land文件夾中,然後你可以看到這個預覽,你可以參考這個https://developer.android.com/guide/practices/screens_support.html – Vij