我想要一個嵌套的片段,它應該佔用剩下的空間。問題是它甚至沒有顯示,因爲高度是1像素。例如,如果我將高度設置爲300 dp,則一切看起來都不錯。這是我的代碼。也許佈局無法計算究竟是其他兩個佈局:填充其餘空間的嵌套片段
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="5dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/white_with_divider_bg"
android:id="@+id/firstL">
</RelativeLayout>
<RelativeLayout
android:id="@+id/secondL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
</RelativeLayout>
<FrameLayout
android:id="@+id/child_fragment"
android:layout_height="0dip"
android:layout_width="match_parent"
android:layout_weight="1"/>
</LinearLayout>
的高度,它應該是這樣的:
您可以使用單個RelativeLayout,而不是使用所有嵌套的佈局(對性能和糟糕的設計不好)。甚至在這種情況下,甚至可以使用一個LinearLayout(它也更快)。 –
佈局複雜,每個子佈局內都有很多視圖,因此我只展示了主邏輯。 – charbinary
對於你所展示的,一個LL就足夠了。如果它更復雜,則考慮使用單個RL。 –