我在布局中有3个FrameLayout
,第一个和第三个有固定高度(子视图的wrap_content)。
我希望第二个FrameLayout
填充第一个和第三个元素之间的剩余空间。
我的XML代码如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal" >
<!-- ... childs views with fixed height -->
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp" <!-- Fill remaining space -->
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp" >
<!-- ... childs views with match_parent height -->
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<!-- ... childs view with fixed height -->
</FrameLayout>
</LinearLayout>
RelativeLayout
作为父级。 - JiTHiNRelativeLayout
,则可以将0dp的FrameLayout声明为最后一个,并给它match_parent
,以填充剩余的高度。 - PhantômaxxFrameLayout
еЃљеђЊж ·зљ„дє‹жѓ…пјЊиЇ·зњ‹@blackbeltзљ„е›ћз” :) - Florian Mac Langlade