2017-02-10 1 views
0

Ich habe hier ein einfaches Layout, aber das LinearLayout in ScrollView stimmt nicht mit der übergeordneten Höhe überein.Höhe des untergeordneten Layouts entspricht nicht dem übergeordneten Layout

<LinearLayout 
    . 
    . 
    android:layout_width = "match_parent" 
    android:layout_height = "match_parent" 
    android:orientation = "vertical" 
    . 
    .> 
    <EditText 
    . 
    ./> 

    <Button 
    . 
    ./> 

    <ScrollView 
     android:layout_width = "match_parent" 
     android:layout_height = "match_parent"> 

     <LinearLayout 
      android:id = "@+id/layoutWeb" 
      android:layout_width = "match_parent" 
      android:layout_height = "match_parent" 
      android:orientation = "vertical"> 

      <ListView 
       android:id = "@+id/listWeb" 
       android:layout_width = "match_parent" 
       android:layout_height = "match_parent"> 

      </ListView> 

     </LinearLayout> 

    </ScrollView> 

</LinearLayout> 

Die ID schlägt vor, die Höhe des linearen Layouts (id = layoutWeb) in wrap_parent zu ändern. Ich habe das lineare Layout in der Abbildung unten gewählt, aber seine Höhe ist die Mutter Screenshot

+1

Nie ListView in ScrollView, und das erste LinearLayout enthält keine Polsterung? –

+0

Ich habe gerade festgestellt, dass das so dumm war. Aber warum sollte es nicht funktionieren? –

+0

match_parent funktioniert nicht im ScrollView-Stammverzeichnis. Auch solltest du neuere Scrolls in andere ScrollViews einfügen (ListView in ScrollView). –

Antwort

3
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 


<LinearLayout 
    android:id="@+id/layoutWeb" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical"> 
    <ListView 
      android:id="@+id/listWeb" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"/> 
</LinearLayout> 

versuchen, diesen Code nicht übereinstimmen. Für die Listenansicht müssen Sie keine scrollview verwenden. es ist bereits scrollbar

+0

Danke. Ich hab es jetzt –

Verwandte Themen