在Android中是否可能有重叠视图?我想有一个图像视图与一个透明的png在前面和另一个在背景视图
编辑:
这就是我目前的情况,问题是imageView中的图像不是透明的,应该是透明的部分只是黑色的
<;RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android"
android:orientation=“垂直”
android:layout\u width=“包装内容”
android:layout\u height=“包装内容”
android:id=“@+id/gallerylayout”
&燃气轮机;
<;画廊android:id=“@+id/概述”
android:layout\u width=“fill\u parent”
android:layout\u height=“包装内容”
/&燃气轮机;
<;ImageView android:id=“@+id/navigmaske”
android:layout\u width=“fill\u parent”
android:layout\u height=“包装内容”
android:src=”https://stackoverflow.com/questions/961944/@可牵引/导航任务“
/&燃气轮机;
</相对寿命>;
编辑:
我让它工作了,它是团队中另一个程序员的主题文件。
只是改变了这个
<;item name=“android:background”>#FF000000</项目>;
对此
<;item name=“android:background”>#00000000</项目>;
Android以本机方式处理视图和绘图(包括PNG图像)之间的透明度,因此您描述的场景(在图库前面部分透明的图像视图)当然是可能的
如果您遇到问题,可能与布局或图像有关。我复制了您描述的布局,并成功实现了您想要的效果。这是我使用的确切布局
<;相对论
xmlns:android=”http://schemas.android.com/apk/res/android"
android:id=“@+id/gallerylayout”
android:layout\u width=“fill\u parent”
android:layout\u height=“fill\u parent”>;
<;陈列室
android:id=“@+id/概述”
android:layout\u width=“fill\u parent”
android:layout\u height=“包装内容”
/&燃气轮机;
<;图片框
android:id=“@+id/navigmaske”
android:background=“#0000”
android:src=”https://stackoverflow.com/questions/961944/@可牵引/导航任务“
android:scaleType=“fitXY”
android:layout_alignTop=“@id/overview”
android:layout_alignBottom=“@id/overview”
android:layout\u width=“fill\u parent”
android:layout\u height=“包装内容”
/&燃气轮机;
</相对寿命>;
请注意,我已将父级RelativeLayout更改为fill\u parent的高度和宽度,这通常是主要活动所需的高度和宽度。然后,我将ImageView的顶部和底部与图库的顶部和底部对齐,以确保它位于前面的中心位置
我还明确地将ImageView的背景设置为透明
至于图像可绘制本身,如果你把PNG文件放在某个地方让我看,我可以在我的项目中使用它,看看它是否负责