Android的,如何把一个图像在另一个图像?

问题描述:

在项目中,我有一个菜单。菜单设计我想使用GridView控件。
为简单起见,假设这个网格视图中只有一个项目。该项目有两个单独的图像(background.png和news.png)和文本(例如新闻)。

In my project I have a menu. for design of menu i want to use 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").

是否有可能映射news.png通过XML或code background.png?

Is it possible to map news.png on background.png through xml or code?

感谢您帮助我。

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

Yes you can always do that using FrameLayout in xml file,Like this.

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