我創建了一個小例子來解釋我的問題。在這個例子中,我創建了一個填充整個屏幕的RelativeLayout。和3個孩子:如何填充父級相對佈局中的所有空間?
- ID爲中間的FrameLayout必須填補所有空白區域沒有覆蓋上的FrameLayout(粉紅色)
- 的FrameLayout id爲頂部必須表現出中等以上(紅色)
- 的FrameLayout的頂部和底部ID爲底部必須出現如下圖所示中間(黃色)
佈局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/top"
android:layout_width="100dp"
android:layout_height="24dp"
android:layout_above="@id/middle"
android:background="#FFFF0000" />
<FrameLayout
android:id="@+id/middle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFF00FF" />
<FrameLayout
android:id="@+id/bottom"
android:layout_width="100dp"
android:layout_height="24dp"
android:layout_below="@id/middle"
android:background="#FFFFFF00" />
</RelativeLayout>
截圖我的示例結果:
而我需要做的截圖:
你有使用'RelativeLayout'? –