2012-07-13 93 views
7

我有一個很簡單的問題要問:我需要在屏幕右下方的Im​​ageView上放大小的標誌,大的屏幕,但我不知道如何設置座標或如何說ImageViews處於相對位置。Android ImageView 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 2012-07-13 10:00:10

回答

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 2012-07-13 10:10:58

+0

'RelativeLayout'是關鍵!我正在使用線性佈局。 – ThunderWiring 2017-08-13 09:27:50

2

使用的FrameLayout。

按照谷歌的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> 

它會給你以下輸出

enter image description here

只是調整,以滿足您的需求。