2012-07-13 28 views
7

Mam dość proste pytanie: muszę umieścić małe logo na ImageView, duży cały ekran, w prawym dolnym obszarze ekranu, ale nie wiem jak ustaw współrzędne lub sposób wyświetlania obrazu w pozycji względnej.Android, ImageView na ImageView

coś takiego:

enter image description here

+0

Możesz zajrzeć do FrameLayout. [Heres] (http://mobileorchard.com/android-app-development-%E2%80%93-layouts-part-three-frame-layout-and-scroll-view/) dobre łącze, mam nadzieję, że pomoże . – Antrromet

Odpowiedz

8

Spróbuj

<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> 

Output

enter image description here

+0

Dzięki temu próbowałem tego i pracowałem przy pierwszej próbie – Stefano

+0

'RelativeLayout' jest kluczem! korzystałem z układu liniowego. – ThunderWiring

2

Zastosowanie FrameLayout.

Zgodnie Google Blogspot Sample

<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> 

która daje następujący wynik

enter image description here

Wystarczy dostosować go do własnych potrzeb.