简体   繁体   English

Android,如何将一个图像放在另一个图像上?

[英]Android, How to put an image over another image?

In my project I have a menu. 在我的项目中,我有一个菜单。 for design of menu i want to use gridView. 对于菜单的设计,我想使用gridView。 for simplicity assume that this grid view has just one item. 为简单起见,假定此网格视图只有一个项目。 This item has two seperate images (background.png and news.png) and a text (for example "NEWS"). 此项目有两个单独的图像(background.png和news.png)和一个文本(例如“ NEWS”)。

Is it possible to map news.png on background.png through xml or code? 是否可以通过xml或代码将news.png映射到background.png上?

Thanks for helping me. 谢谢你帮我

Yes you can always do that using FrameLayout in xml file,Like this. 是的,您始终可以使用xml文件中的FrameLayout来做到这一点,就像这样。

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM