2013-02-12 48 views
17
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:background="#000000" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <LinearLayout 
      android:id="@+id/linear1" 
      android:background="#FF0000" 
      android:orientation="vertical" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" > 

      <LinearLayout 
       android:background="#00FF00" 
       android:id="@+id/linear2" 
       android:layout_width="match_parent" 
       android:layout_height="200dip" 
       android:orientation="vertical" > 
      </LinearLayout> 

      <LinearLayout 
       android:background="#0000FF" 
       android:id="@+id/linear3" 
       android:layout_width="match_parent" 
       android:layout_height="100dip" 
       android:orientation="vertical" > 
      </LinearLayout> 

     </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 

Đây là cách bố trí của tôi và tôi mong đợi để xem một nền đỏ (vì linear1 có nền đỏ và có các tính chất để điền vào công ty mẹ), và hai người khác bố trí với so với linear1 với màu xanh lá cây và xanh da trời bacgroudnsLàm thế nào để làm cho LinearLayout trong scrollview để lấp đầy toàn bộ khu vực

nhưng những gì tôi thực sự thấy là bacground đen từ scrollview và màu xanh lá cây và màu xanh từ linear2 và linear3 nhưng không backgrund đỏ từ linear1

cụ thể là tuyến tính là hành động như android: layout_height = "wrap_content" được đặt không phải là android: layout_height = "match_parent"

bất kỳ ý tưởng nào?

Trả lời

59

Bạn không cần thiết fillViewport:

<ScrollView 
    android:id="@+id/scrollView1" 
    android:background="#000000" 
    android:layout_width="match_parent" 
    android:fillViewport="true" <!-- here --> 
    android:layout_height="match_parent" > 

    ... 

</ScrollView> 

information

+0

cảm ơn! Điều này thực sự làm việc – Amos

+2

làm thế nào để sửa linearlayout với weightsum bên trong scrollview? – karthick

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