2010-08-20 34 views
5

Tôi có bố cục chỉ hiển thị ScrollView. Nó có một bố trí tương đối như con của nó. Bố cục này có một số bố trí khác (chủ yếu là lượt xem văn bản) như các con của nó. Khi văn bản không đủ lớn, chế độ xem cuộn không tự mở rộng để vừa với toàn bộ màn hình. Thay vào đó, nó cho thấy một khoảng trống ở phía dưới, nơi nền hiển thị. Tôi đã thử thiết lập fillViewPort=true trên ScrollView, nhưng điều đó vừa tạo bố cục con đầu tiên (RL1) để lấp đầy màn hình.Làm thế nào để làm cho ScrollView với RelativeLayout với nhiều bố cục con lấp đầy màn hình?

<?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> 

Trả lời

5

fillViewMục nên điền FillViewport

Các vấn đề liên quan