2012-07-13 17 views
7

私は非常に簡単な質問をしています。画面の右下にあるImageViewに小さなロゴを入れる必要があります。座標を設定するか、ImageViewsを相対位置にする方法を設定します。Android、ImageView over ImageView

このような何か:

enter image description here

+0

FrameLayoutを見ることができます。 [Heres](http://mobileorchard.com/android-app-development-%E2%80%93-layouts-part-three-frame-layout-and-scroll-view/)良いリンク、それがあなたを助けることを願って。 – Antrromet

答えて

8

この

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

出力

enter image description here

+0

ありがとう私はこれを試して、最初の試行で働いた – Stefano

+0

'RelativeLayout'が鍵です!私は線形レイアウトを使用していました。 – ThunderWiring

2

使用でframeLayoutを試してみてください。ちょうどあなたのニーズに合わせてそれを微調整あなたの次の出力

enter image description here

を与えるGoogleのBlogspotのあたりのサンプル

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

として