Scrollview "adopts" 一个列表项的高度

Scrollview "adopts" the height of one list item

我有一个包含项目 ListView 的片段。这个ListView在ScrollView中。当我启动我的应用程序时,滚动视图采用一个列表项的高度。如何将 ScrollView 展开到全屏?

我的 xml 片段:

<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="match_parent">
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ListView
        android:id="@+id/lvData"
        android:layout_width="match_parent"
        android:layout_height="fill_parent">
    </ListView>
</ScrollView>
</RelativeLayout> 

Xml 个列表项:

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout
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"
android:layout_marginTop="10dp">

<TextView
    android:layout_width="45dp"
    android:layout_height="45dp"
    android:id="@+id/tv_number"
    android:layout_gravity="left|center_vertical"
    android:background="@drawable/oval"
    android:textAlignment="center"
    android:textIsSelectable="false"
    android:textStyle="normal|bold"
    android:textSize="40sp"
    android:layout_marginLeft="20dp"
    android:text="@string/number"
    android:textColor="#ffffff"
    tools:targetApi="jelly_bean_mr1" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/lesson_name"
    android:id="@+id/tv_lesson"
    android:layout_gravity="center_horizontal|top"
    android:textAlignment="center"
    android:textStyle="normal|bold"
    android:textSize="20sp"
    tools:targetApi="jelly_bean_mr1" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Время"
    android:id="@+id/tv_time"
    android:layout_gravity="center"
    android:layout_marginTop="4dp"
    android:layout_marginBottom="10dp" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/teacher_name"
    android:id="@+id/tv_teacher"
    android:layout_gravity="center_horizontal|bottom"
    android:textStyle="italic" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Кабинет"
    android:id="@+id/tv_cab"
    android:layout_gravity="right|bottom"
    android:layout_marginTop="4dp"
    android:layout_marginBottom="17dp" />
</FrameLayout>

截图

http://i.stack.imgur.com/dSbaB.jpg
http://i.stack.imgur.com/fsgd3.jpg
http://i.stac k.imgur.com/oVKGJ.jpg

将列表视图包含在滚动视图中是个坏主意。 你不需要滚动视图,列表会自己滚动,也会适应屏幕大小,所以只需删除滚动布局,列表视图就会填满屏幕 所以布局将是

<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="match_parent">

<ListView
    android:id="@+id/lvData"
    android:layout_width="match_parent"
    android:layout_height="fill_parent">
</ListView>
</RelativeLayout>