Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.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
Java 将两个图像视图放置在另一个图像视图的顶部_Java_Android_Xml - Fatal编程技术网

Java 将两个图像视图放置在另一个图像视图的顶部

Java 将两个图像视图放置在另一个图像视图的顶部,java,android,xml,Java,Android,Xml,我正在尝试将2个imageView放置在另一个imageView的顶部。这就是我想要完成的。 所以我想要的是,imageView#2将被放置在与图片中imageView#1完全相同的位置。这是我迄今为止所尝试的,但它没有像我想要的那样工作。当我在不同的设备中尝试时,图像未保持准确位置:( 提前感谢。一个选项必须是使用 或者使用 <RelativeLayout android:layout_width="wrap_content" android:layout_height="wra

我正在尝试将2个imageView放置在另一个imageView的顶部。这就是我想要完成的。

所以我想要的是,imageView#2将被放置在与图片中imageView#1完全相同的位置。这是我迄今为止所尝试的,但它没有像我想要的那样工作。当我在不同的设备中尝试时,图像未保持准确位置:(



提前感谢。

一个选项必须是使用

或者使用

<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
    <ImageView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image_bottom"/>
    <ImageView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image_top" android:layout_alignParentBottom="true" android:layout_alignParentRight="true"/>
</RelativeLayout>

更新:我发现这个@Stackoverflow:

试试这段代码,我用它来显示重叠播放图像的视频拇指
<RelativeLayout android:layout_width="wrap_content" android:layout_height="wrap_content">
    <ImageView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image_bottom"/>
    <ImageView  android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/image_top" android:layout_alignParentBottom="true" android:layout_alignParentRight="true"/>
</RelativeLayout>
`


`
根据您的要求更改高度和宽度

<FrameLayout
                android:id="@+id/playVideo"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
                <ImageView
                    android:id="@+id/videoImage"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:scaleType="center"
                    android:src="@drawable/videoThumb" />
                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:scaleType="centerCrop"
                    android:layout_margin="10dp"
                    android:src="@drawable/play_button"/>
            </FrameLayout>`