Android中是否可以有重叠的视图?我想要一个 ImageView,前面有一个透明的 png,背景有另一个视图。
编辑:
这就是我目前的情况,问题是imageView中的图像不透明,应该透明的部分只是黑色。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/gallerylayout"
>
<Gallery android:id="@+id/overview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ImageView android:id="@+id/navigmaske"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/navigmask"
/>
</RelativeLayout>
编辑:
我让它工作了,它是团队中另一个程序员的主题文件。刚改了这个
<item name="android:background">#FF000000</item>
对此
<item name="android:background">#00000000</item>
原文由 Alexander Stolz 发布,翻译遵循 CC BY-SA 4.0 许可协议
Android本机处理视图和可绘制对象(包括PNG图像)的透明度,因此您描述的场景(部分透明的
ImageView
在Gallery
前面)当然是可能的。如果您遇到问题,可能与布局或图像有关。我已经复制了您描述的布局并成功实现了您所追求的效果。这是我使用的确切布局。
请注意,我已将父
RelativeLayout
fill_parent
高度和宽度,这通常是您想要的主要活动。然后我将ImageView
Gallery
顶部和底部对齐,以确保它在它前面居中。我还明确将
ImageView
的背景设置为透明。至于可绘制图像本身,如果您将 PNG 文件放在某个地方供我查看,我可以在我的项目中使用它,看看它是否负责。