/ / Comment gérer correctement FrameLayout imbriqué - Android, Android-layout, Android-imageview, relativelayout, framelayout

Comment gérer correctement FrameLayout imbriqué - android, android-layout, android-imageview, relativelayout, framelayout

J'utilise FrameLayouts pour superposer une image à une autre, mais je ne peux pas comprendre dans ce scénario particulier où mon FrameLayout intérieur ne s'affiche pas à l'avant d'une autre image. Voici la théorie:

théorie

et voici la chose réelle:

réel

Alors voici mon 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>

Ai-je mal placé le FrameLayout interne? Je ne sais plus comment faire. Toute aide sera très appréciée. Merci!

Réponses:

2 pour la réponse № 1

C'est parce que votre FrameLayout a cette ligne: android:layout_below="@id/cover_photo". Vous pouvez avoir FrameLayout comme ceci:

<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="-40dp"
android:layout_alignBottom="@id/cover_photo" >