arbeitete ich folgendes Layout haben:Linearlayout mit LayoutWeight nicht
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_brand"
android:weightSum="100">
<LinearLayout
android:id="@+id/top"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="40"
android:background="@color/color_white">
<View
android:layout_width="match_parent"
android:layout_height="10dp"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/middle"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="20"
android:background="@color/color_black"
android:layout_below="@id/top">
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
</LinearLayout>
<LinearLayout
android:id="@+id/bottom"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="40"
android:background="@color/color_white"
android:layout_below="@id/middle">
<View
android:layout_width="match_parent"
android:layout_height="10dp"/>
</LinearLayout>
</RelativeLayout>
Ich möchte eine 40-20-40 Spaltung zwischen den Layouts, und ich habe alles versucht, aber nichts scheint zu funktionieren. Ich habe versucht, eine leere Ansicht in den linearen Layouts hinzuzufügen, ich habe den Ansichten im linearen Layout das Gewicht gegeben, aber nichts funktioniert. Kann jemand darauf hinweisen, was ich falsch mache?
Ändern Sie einfach Ihr übergeordnetes Layout von RelativeLayout zu LinearLayout. Es funktioniert –
Gewichte funktionieren nicht auf RELATIVE LAYOUT als Eltern, Sie müssen LINEAR LAYOUT als Eltern verwenden. - –
Danke Jungs. Ich kann nicht glauben, dass ich das nicht verstanden habe. – BlackHatSamurai