LinearLayout füllt ScrollView nicht aus

S

samarek

Fortgeschrittenes Mitglied
2
Hi

ich hab hier eine ScrollView in der ein LinearLayout mit diversen Elementen liegt, unter anderem mit einem ListView in dem mehrere Elemente aus der Datenbank angezeigt werden.

Jetzt habe ich folgendes Problem damit und zwar füllt das LinearLayout die ScrollView nicht aus (nur zu etwa 2/3), das LinearLayout steht auf layout_height="match_parent", es sind sonst keine Sachen in der ScrollView (geht ja auch nicht).

Kann mir das mal jemand erläutern?
 
Code? ;)
 
sind 240 zeilen und ich find das etwas zu lang um es einfach stumpf zu posten, aber gut, wenn du es willst

Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ScrollView 
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">
        <LinearLayout 
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout 
                android:orientation="horizontal"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center">
                <LinearLayout 
                    android:orientation="vertical"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0">
                    <TextView 
                        android:text="@string/rsaArt"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="@dimen/rand"
                        android:layout_marginRight="@dimen/rand"
                        android:layout_gravity="left"
                        style="@style/text_schwarz"
                        />
                    <TextView 
                        android:text="@string/rsaDimension"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginRight="@dimen/rand"
                        android:layout_marginLeft="@dimen/rand"
                        android:layout_gravity="left"
                        style="@style/text_schwarz"
                        />
                    <TextView 
                        android:text="@string/rsaSpeedIndex"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="0"
                        android:layout_marginLeft="@dimen/rand"
                        android:layout_marginRight="@dimen/rand"
                        android:layout_gravity="left"
                        style="@style/text_schwarz"
                        />
                    <TextView 
                        android:text="@string/rsaHersteller"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_weight="0"
                        android:layout_marginLeft="@dimen/rand"
                        android:layout_marginRight="@dimen/rand"
                        android:layout_gravity="left"
                        style="@style/text_schwarz"
                        />
                </LinearLayout>
                <LinearLayout 
                    android:orientation="vertical"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1">
                    <EditText 
                        android:id="@+id/etx_rsaArt"
                        android:text=" Sommerreifen"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/reifen_edittext_gross"
                        android:layout_marginRight="@dimen/randKlein"                
                        android:layout_marginLeft="1dp"
                        android:focusable="false"
                        style="@style/text_schwarz"
                        />
                    <LinearLayout 
                        android:orientation="horizontal"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginTop="5dp">
                        <EditText 
                            android:id="@+id/etx_rsaDimensionBreite"
                            android:text=" 195"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/reifen_edittext"
                            android:layout_marginRight="@dimen/randKlein"
                            android:layout_marginTop="0dp"
                            android:focusable="false"                
                            style="@style/text_schwarz"
                            />
                        <TextView 
                            android:text="/"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"                
                            android:layout_marginTop="0dp"            
                            style="@style/text_schwarz"
                            />
                        <EditText 
                            android:id="@+id/etx_rsaDimensionQuer"
                            android:text=" 65"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/reifen_edittext"
                            android:layout_marginRight="@dimen/randKlein"
                            android:layout_marginTop="0dp"
                            android:focusable="false"
                            style="@style/text_schwarz"
                            />
                        <EditText 
                            android:id="@+id/etx_rsaDimensionZoll"
                            android:text=" R 15"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:background="@drawable/reifen_edittext"
                            android:layout_marginRight="@dimen/randKlein"
                            android:layout_marginTop="0dp"
                            android:focusable="false"
                            style="@style/text_schwarz"
                            />
                    </LinearLayout>
                    <EditText 
                        android:id="@+id/etx_rsaSpeedindex"
                        android:text=" Alle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@drawable/reifen_edittext_gross"
                        android:layout_marginRight="@dimen/randKlein"
                        android:layout_marginLeft="1dp"
                        android:focusable="false"
                        style="@style/text_schwarz"
                        />
                    <EditText 
                        android:id="@+id/etx_rsaHersteller"
                        android:text=" Alle"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="1"
                        android:background="@drawable/reifen_edittext_gross"
                        android:layout_marginRight="@dimen/randKlein"
                        android:layout_marginLeft="1dp"
                        android:focusable="false"
                        style="@style/text_schwarz"
                        />
                </LinearLayout>
            </LinearLayout>
            <LinearLayout 
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/rand" 
                android:gravity="right">
                <Button 
                    android:id="@+id/btn_rsaSuchen"
                    android:text="@string/btnSuchen"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="0dp"
                    android:layout_marginRight="@dimen/randGross"
                    android:gravity="center"
                    style="@style/button_layout"
                    />
            </LinearLayout>
            <LinearLayout 
                android:orientation="vertical"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="@dimen/randGross">
                <LinearLayout
                    android:id="@+id/lla_rsaTabelle"
                    android:orientation="horizontal"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_marginRight="@dimen/randGross">
                    <LinearLayout 
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="2"
                        android:layout_gravity="left">
                        <TextView 
                            android:text="@string/rsaTabMarke"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center_horizontal"
                            style="@style/text_schwarz"
                            />
                    </LinearLayout>
                    <LinearLayout 
                        android:orientation="vertical"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_weight="3"
                        android:layout_gravity="center_horizontal">
                        <TextView
                            android:text="@string/rsaTabAusf" 
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center_horizontal"
                            style="@style/text_schwarz"
                            />
                    </LinearLayout>
                    <LinearLayout 
                        android:orientation="vertical"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_gravity="right">
                        <TextView 
                            android:text="@string/rsaTabPreis"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:gravity="center_horizontal"
                            android:layout_marginLeft="@dimen/randKlein"
                            style="@style/text_schwarz"
                            />
                    </LinearLayout>
                </LinearLayout>
                <ListView
                    android:id="@+id/lsv_rsaTabelle" 
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:cacheColorHint="@color/transparent"
                    >
                </ListView>
            </LinearLayout>
            <TextView 
                android:id="@+id/txv_rsaKeineReifen"
                android:text="@string/rsaKeineReifen"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                style="@style/text_schwarz"
                />
        </LinearLayout>
    </ScrollView>
</LinearLayout>

also, was ich machen will sollte ja klar sein, denke ich, Suchmaske und dadrunter eine Liste mit Ergebnissen bzw. einem "keine Ergebnisse"-TextView und das ganze soll dann so scrollbar werden dass sich auch die Suchmaske nach oben aus dem Bild schieben lässt wenn die Liste entsprechend lang wird.
 
Nur als tipp, füttere mal layoutopt damit, das erste Linearlayout scheint mir sinnlos zu sein.
 
interessant, das Tool kannte ich noch garnicht
hat aber auch keine brauchbaren Hinweise ausgespuckt, wobei "vertically scrolling ScrollView should not contain vertically scrolling widget" gut klang, aber hab damit grad experimentiert und das hat auch nichts geändert
 
La problema war offenbar ein ganz anderes

ListView in einem ScrollView geht anscheinend immer kaputt (Stand: ca. 2010, vielleicht ist es in neueren Versionen gefixed)

jedenfalls habe ich mir jetzt mit diesem Work-around weitergeholfen:
Ore Ni Makasero: Android: put ListView in a ScrollView
damit rechnet man halt aus wie groß das ListView werden würde und setzt die Größe dann manuell, damit funktioniert es aufjedenfall (bei mir)
 

Ähnliche Themen

R
  • Robby1950
2
Antworten
23
Aufrufe
998
Robby1950
R
B
Antworten
6
Aufrufe
1.046
jogimuc
J
SaniMatthias
Antworten
19
Aufrufe
934
swa00
swa00
Zurück
Oben Unten