2012-02-29 91 views
1

在我的项目中,我有一个菜单。对于我想要使用gridView的菜单设计。为简单起见,假定此网格视图只有一个项目。这个项目有两个独立的图像(background.png和news.png)和一个文本(例如“NEWS”)。Android,如何将图片放在另一张图片上?

是否可以通过xml或代码将background.png上的news.png映射到background.png上?

感谢您的帮助。

+0

你想显示两个图像在另一个... – 2012-02-29 05:11:51

+0

是的,我想知道它是否实用? – Hesam 2012-02-29 05:46:25

+0

@Hesam你有没有找到任何解决方案> – PriyankaChauhan 2016-11-02 10:29:14

回答

1

是的你可以随时使用FrameLayout在xml文件中,像这样。

<FrameLayout android:id="@+id/frameLayout1" 
    android:layout_width="fill_parent" android:layout_height="fill_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 
    <ImageView android:id="@+id/imageView1" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:src="@drawable/background"></ImageView> 
    <ImageView android:id="@+id/imageView2" android:layout_width="wrap_content" 
     android:layout_gravity="center" android:layout_height="wrap_content" 
     android:src="@drawable/news"></ImageView> 
    <TextView android:text="NEWS" android:id="@+id/textView1" android:layout_gravity="bottom|center_horizontal" 
     android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView> 
</FrameLayout> 
+0

或者你可以设置父母布局的android:background属性(但它会扩展到布局大小)。 – Sver 2012-02-29 05:52:13

+0

@Sver你的意思是说采取布局设置背景,并在该线性布局采取imageview和textview?..是的,可以工作..可能不看好编程,但可以实现相同的结果。 – MKJParekh 2012-02-29 05:57:03

+0

好吧,如果背景图像只是简单的背景图像没有太多细节..为什么不呢?在FrameLayout的情况下,您需要考虑图像的大小。 – Sver 2012-02-29 06:01:15

相关问题