在Android Studio上的现有背景上添加多个图像

时间:2015-07-24 20:40:21

标签: android

我是Android编程的新手,我想在已经存在的网格现有背景中添加图片。

这是我的背景图片,我想在背景的左侧和右侧添加小图像。说我设计的动画图像,但我不知道该程序。任何帮助将不胜感激。

enter image description here

1 个答案:

答案 0 :(得分:1)

如果要将图像放在背景图像的前面,最好使用FrameLayout或RelativeLayout。如果你不希望它在顶部而在侧面,你应该在"水平"中使用LinearLayout。取向。

<FrameLayout android:id="@+id/my_ph"    
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView  
    android:id="@+id/background_image"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/sketch" android:layout_alignParentTop="true"/>

<ImageView  
    android:id="@+id/image2"
    android:layout_width="fill_parent" 
    android:layout_height="fill_paren" 
    android:layout_alignTop="@id/image"
    android:layout_alignLeft="@id/image"
    android:layout_alignRight="@id/image"
    android:layout_alignBottomp="@id/image"
</FrameLayout>

<LinearLayout
android:id="@+id/my_ph"    
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<ImageView  
    android:id="@+id/image1"
    android:layout_width="fill_parent" 
    android:layout_height="fill_paren" </>

<ImageView  
    android:id="@+id/background_image"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/sketch" android:layout_alignParentTop="true"/>

<ImageView  
    android:id="@+id/image2"
    android:layout_width="fill_parent" 
    android:layout_height="fill_paren" </>
</LinearLayout>