Ich habe vier Elemente in einem linearen Layout.Ausrichten von Elementen in einem LinearLayout, das den halben Bildschirmplatz einnimmt
Ich möchte sie so ausrichten, dass classALabel
& classBLabel
nebeneinander nebeneinander die halbe Breite des Bildschirms ausgerichtet sind.
Und classA
& classB
auch direkt neben einander Seite an Seite unter Halb halbe Breite des Bildschirms, aber unterhalb classALabel
& classBLabel
ausgerichtet sind.
Unten ist, was ich bisher versucht habe, aber das funktioniert nicht so, wie ich will. Es zeigt nur alle vier Elemente nebeneinander, die jeweils 25% Platz auf dem Bildschirm geben.
<LinearLayout
android:id="@+id/ClassALayout"
android:layout_width="match_parent"
android:layout_height="@dimen/tile_height"
android:layout_below="@+id/ClassLayout"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:orientation="horizontal">
<TextView
android:id="@+id/classALabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/classALabel" />
<TextView
android:id="@+id/classA"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/classALabel"
android:layout_marginTop="@dimen/dimen_2"
android:layout_alignParentLeft="true"
android:layout_weight="1"
/>
<TextView
android:id="@+id/classBLabel"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/classA"
android:layout_weight="1"
android:text="@string/classBLabel" />
<TextView
android:id="@+id/classB"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_below="@+id/classBLabel"
android:layout_marginTop="@dimen/dimen_2"
android:layout_weight="1"
/>
</LinearLayout>