2012-07-13 6 views
7

J'ai une question assez simple à poser: je dois mettre un petit logo sur un ImageView, grand tout l'écran, dans la partie inférieure droite de l'écran, mais je ne sais pas comment Définissez les coordonnées ou comment dire que les ImageViews sont dans une position relative.Android, ImageView over ImageView

Quelque chose comme ceci:

enter image description here

+0

Vous pouvez regarder dans FrameLayout. [Heres] (http://mobileorchard.com/android-app-development-%E2%80%93-layouts-part-three-frame-layout-and-scroll-view/) un bon lien, j'espère que ça vous aidera . – Antrromet

Répondre

8

Essayez cette

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:src="@drawable/ic_launcher" /> 

    <ImageView 
     android:id="@+id/imageView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:src="@drawable/ic_launcher" /> 

</RelativeLayout> 

Sortie

enter image description here

+0

Merci J'ai essayé cela et a travaillé au premier essai – Stefano

+0

'RelativeLayout' est la clé! J'utilisais la disposition linéaire. – ThunderWiring

2

Utilisez FrameLayout.

Comme par Google Blogspot Exemple

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <ImageView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 

     android:scaleType="center" 
     android:src="@drawable/golden_gate" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginBottom="20dip" 
     android:layout_gravity="center_horizontal|bottom" 

     android:padding="12dip" 

     android:background="#AA000000" 
     android:textColor="#ffffffff" 

     android:text="Golden Gate" /> 

</FrameLayout> 

qui vous donnera suite à la sortie

enter image description here

tweak Il suffit pour répondre à vos besoins.