如何使包含多个子布局的RelativeLayout的ScrollView填充整个屏幕?

5

我有一个布局,只显示一个ScrollView。它的子元素是RelativeLayout。该布局有几个其他布局(主要是TextView)作为其子元素。当文本不够大时,滚动视图不会自动扩展以适合整个屏幕。相反,它在底部显示一个空白的背景。我尝试在ScrollView上设置fillViewPort=true,但这只是使第一个子布局(RL1)填充整个屏幕。

<?xml version="1.0" encoding="utf-8"?>
  <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/background_image">

   <ProgressBar android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:visibility="gone"/>

    <ScrollView
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:fillViewPort="true"
      android:scrollbars="none">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingTop="10px">

      <RelativeLayout android:id="@+id/list"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:paddingTop="10px">

        <!-- This layout is filling the screen if I set fillViewPort="true" -->
        <RelativeLayout  android:id="@+id/RL1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

            <!--TextViews and ImageViews -->

       </RelativeLayout>

        <RelativeLayout android:id="@+id/RL2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

            <!--TextViews and ImageViews -->

        </RelativeLayout>

        <RelativeLayout android:id="@+id/RL3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            <!--TextViews and ImageViews -->

        </RelativeLayout>

        <RelativeLayout  android:id="@+id/RL4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content">

            <!--TextViews and ImageViews -->

        </RelativeLayout>

     </RelativeLayout>

   </RelativeLayout>

  </ScrollView>

</FrameLayout>
1个回答

5

fillViewPort 应该是 fillViewport。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接