1

我正在使用 FrameLayouts 将图像重叠在图像上,但在这种特殊情况下我无法理解我的内部 FrameLayout 没有显示在另一个图像的前面。这是理论:

理论

这是实际情况:

实际的

所以这是我的 XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mypage_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >

<FrameLayout
    android:id="@+id/frame"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

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

        <ImageView
            android:id="@+id/cover_photo"
            android:layout_width="match_parent"
            android:layout_height="180dp"
            android:layout_marginTop="120dp"
            android:scaleType="fitXY"
            android:src="#CCFF0000" />

        <FrameLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/cover_photo" >

            <ImageView
                android:layout_width="105dp"
                android:layout_height="90dp"
                android:layout_below="@id/cover_photo"
                android:adjustViewBounds="true"
                android:src="@color/aqua"
                android:translationY="-45dp" />

            <ImageView
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginLeft="15dp"
                android:src="@color/green"
                android:translationY="-40dp" />
        </FrameLayout>

    </RelativeLayout>
</FrameLayout>

我把内部 FrameLayout 放错了吗?我不知道该怎么办了。任何帮助将不胜感激。谢谢!

4

1 回答 1

2

这是因为您的 FrameLayout 有这一行:android:layout_below="@id/cover_photo". 你可以像这样拥有 FrameLayout:

<FrameLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="-40dp"
        android:layout_alignBottom="@id/cover_photo" >
于 2013-07-19T08:22:46.570 回答