Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 安卓,如何将一个图像置于另一个图像之上?_Android_Image_Gridview - Fatal编程技术网

Android 安卓,如何将一个图像置于另一个图像之上?

Android 安卓,如何将一个图像置于另一个图像之上?,android,image,gridview,Android,Image,Gridview,在我的项目中,我有一个菜单。对于菜单的设计,我想使用gridView。 为简单起见,假设此网格视图只有一项。此项有两个单独的图像(background.png和news.png)和一个文本(例如“news”) 是否可以通过xml或代码将news.png映射到background.png上 谢谢您的帮助。是的,您可以始终使用xml文件中的这样做 <FrameLayout android:id="@+id/frameLayout1" android:layout_width="fill

在我的项目中,我有一个菜单。对于菜单的设计,我想使用gridView。 为简单起见,假设此网格视图只有一项。此项有两个单独的图像(background.png和news.png)和一个文本(例如“news”)

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


谢谢您的帮助。

是的,您可以始终使用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>

是的,您可以在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>


u想一幅一幅地显示两幅图像……是的,我想知道它是否实用@Hesam你找到解决方案了吗>你想一张一张地展示两张图片…是的,我想知道它是否实用@Hesam你找到解决方案了吗>,或者你可以只设置父布局的android:background属性(但它会延伸到布局大小)。@Sver你的意思是说在线性布局中设置布局背景并拍摄imageview和textview?。是的,这可以工作..可能看起来不太好,但可以实现相同的结果。嗯,如果背景图像只是简单的背景图像,没有太多细节。。为什么不呢?如果是FrameLayout,您需要考虑图像的大小。@MKJParekh我正在使用上述代码,但当我得到FrameLayout的大小作为屏幕大小返回时,如何解决它?或者您可以只设置父布局的android:background属性(但它将延伸到布局大小)@Sver你的意思是说在线性布局中设置背景并拍摄imageview和textview?.yeh这可以工作..可能看起来不太好,但可以实现相同的结果。嗯,如果背景图像只是简单的背景图像,没有太多细节。。为什么不呢?如果是FrameLayout,您需要考虑图像的大小。@MKJParekh我使用的是上面的代码,但是当我得到FrameLayout的大小作为屏幕大小返回时,如何解决它?