2011-01-07 2 views
0

Ich möchte eine Website haben, die ein vertikales Layout enthält, das einen Inhaltsteil und einen Fußteil hat. Der Fußteil sollte 20% der Höhe der Displayhöhe betragen. Ich denke, dass es ein sehr häufiger Anwendungsfall ist.Android Layout LinearLayoutProblem

Ich habe einige Wege versucht, war aber am Ende nicht erfolgreich.

Wie würde ich das umsetzen?

TU im Voraus!

Antwort

0
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:weightSum="-1"> 
    <LinearLayout 
     android:id="@+id/header" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="20"/> 
    <LinearLayout 
     android:id="@+id/body" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="60"/> 
    <LinearLayout 
     android:id="@+id/footer" 
     android:layout_width="fill_parent" 
     android:layout_height="0dip" 
     android:layout_weight="20"/> 
</LinearLayout> 

Dies Sie eine Kopf- und Fußzeile geben sollte, die 20 nehmen % des Raumes, wobei der Körper 60% besetzt. Eine einfache Beschreibung dessen, was das tut, finden Sie unter http://developer.android.com/reference/android/widget/LinearLayout.html#setWeightSum(float).

+0

Ich musste hinzufügen Android: layout_height = "0dip" für jede innere LinearLayout zu arbeiten. Aber dann funktioniert es gut. TU! – Fesp

+0

Ich werde meine Antwort aktualisieren, um das zu reflektieren. Prost! – WorkerThread

0

Dies ist, was für mich funktionierte, um eine Fußzeile mit Anzeigen anzuzeigen.

<LinearLayout> 
<LinearLayout xmlns:myapp="http://schemas.android.com/apk/res/com.broschb.wiiscale" 
    android:layout_width="fill_parent" android:layout_marginTop="5px" 
    android:layout_below="@+id/weight" android:layout_height="fill_parent" 
    android:gravity="center_horizontal|bottom"> 

    <myFooterComponents android:layout_width="fill_parent" android:layout_height="wrap_content"/> 
</LinearLayout> 
</LinearLayout> 
0

LinearLayout, richtig? Stellen Sie einfach die Höhe der sowohl Ihre Inhalte und Fußzeile Layouts fill_parent, und geben Sie dem Inhaltsbereich eine layout_weight von 8 und der Fußzeile eine layout_weight von 2.