2013-04-08 119 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最后一个孩子是最顶部可见视图