2013-02-12 17 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> 

Das ist mein Layout zu füllen und ich erwartete einen roten Hintergrund zu sehen (weil linear1 hat Hintergrund rot und haben Eigenschaften, die Eltern zu füllen), und zwei andere Layouts mit über die linear1 mit grünem und blauen bacgroudnsWie das Linearlayout in Scrollview machen das ganze Gebiet

aber was ich wirklich sehe, ist schwarz bacground von der Scrollview und grün und blau von linear2 und linear3 aber keinen roten Backgrund grund~~POS=HEADCOMP von linear1

nämlich die linearen wie android handeln: layout_height = "wrap_content" ist nicht gesetzt android: layout_height = "match_parent"

irgendwelche Ideen?

Antwort

59

Sie brauchen gesetzt 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

Dank! das funktioniert wirklich – Amos

+2

Wie Linearlayout mit Wensum in Scrollview zu beheben? – karthick

Verwandte Themen