RelativeLayout将两个容器放在另一个容器之上 - Android

时间:2013-08-01 12:20:27

标签: android relativelayout

有人可以告诉我这是否可行?我有一个RelativeLayout,我希望显示两个FrameLayout,一个在另一个之上。我希望它位于底部的那个,width属性设置为wrap_content,另一个应该占用其父级的所有空间。

这就是我所拥有的,而且它不起作用。问题是上面的布局没有显示,只有底部的布局。

这是我的代码:

    <RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <FrameLayout
        android:id="@+id/upper_fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/down_container" >
    </FrameLayout>

    <FrameLayout
        android:id="@+id/down_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginTop="4dip" />
</RelativeLayout>

我在这里做错了吗?

1 个答案:

答案 0 :(得分:1)

将android:layout_above =“@ + id / down_container”更改为android:layout_above =“@ id / down_container”

@ + id /用于创建id,@ id /用于提供此特定组件的引用。

相关问题