Fehler im Layout

  • 1 Antworten
  • Letztes Antwortdatum
H

Hackle

Neues Mitglied
0
Hallo zusammen,

ich versuche seit einigen Stunden ein Layout zu erstellen. Ich schaffe es aber nicht dass es so aussieht wie ich es mir vorstelle. So sieht es bisher aus:

HTML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background"
    android:orientation="vertical"
    tools:context=".GameSettingsActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:paddingLeft="10dp"
        android:text="Header"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:weightSum="100" >

        <ListView
            android:id="@+id/list_players"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="50"
            android:paddingLeft="2dp" >

        </ListView>

        <ListView
            android:id="@+id/list_natures"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="50"
            android:paddingLeft="2dp" >

        </ListView>

    </LinearLayout>

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:text="OK" />

</LinearLayout>

Das Problem ist, dass der Button ganz unten nicht mehr dargestellt wird.
Wenn ich bei dem LinearLayout (das die zwei ListViews enthält) das Gewicht (Weight) auf 1 setze (und Height auf 0dp) dann wird der Button korrekt angezeigt. Allerdings bekomme ich dann diese Warnung:

Nested weights are bad for performance

Wie wäre hier das richtige Vorgehen?

Danke schon mal für eure Hilfe :)

Grüße,
Hackle
 
Button an den unteren Rand bekommt man am besten mit einem RelativeLayout hin. Dabei deklariert man den Button als erstes (mit layout_alignParentBottom) und baut dann den ListeView (hab mir dein konkretes Problem jetzt nicht im Detail angeguckt) dann darüber (layout_above).
 
Zurück
Oben Unten