2013-04-08 88 views
1

我想放置2個ImageView,一個在另一個之上。 這是一個正方形和一個圓的例子。如何覆蓋指定位置的2個圖像瀏覽

enter image description here

我怎麼能這樣做?我只知道在運行時使用哪些圖像,所以我不能在xml文件中指定它們。

預先感謝您。

+3

*嘗試刷的污垢擦掉屏幕*哦.... – dymmeh 2013-04-08 21:44:14

+0

ahahahahahaha對不起XD – 2013-04-09 07:22:03

回答

4

您可以使用FrameLayout彼此堆疊視圖。

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/img_green" /> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/img_red"/> 
</FrameLayout> 

,那麼你可以設置android:layout_margin=""正確定位ImageView秒。

注意的FrameLayout最後一個孩子是最頂部可見視圖