是否有可能具有在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>
有帮助吗?

解决方案

的Android处理跨视图和绘图(包括PNG图像)本身的透明性,所以场景你描述(在ImageView前方的部分透明Gallery)当然是可能的。

如果您遇到可能涉及到无论是布局还是你的形象问题。我复制你描述的布局,成功实现你后的效果。下面是我所用的确切布局。

<RelativeLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/gallerylayout"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent">
  <Gallery
    android:id="@+id/overview"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
  />
  <ImageView
    android:id="@+id/navigmaske"
    android:background="#0000"      
    android:src="@drawable/navigmask"
    android:scaleType="fitXY"
    android:layout_alignTop="@id/overview"
    android:layout_alignBottom="@id/overview"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
  />
</RelativeLayout>

请注意,我已经改变了父RelativeLayout的高度和fill_parent的宽度通常是你想要的一个主要活动。然后我对准ImageViewGallery的顶部和底部的顶部和底部,以确保它集中在它的前面。

我还明确设置ImageView的背景是透明的。

对于图像绘制本身,如果你把PNG文件某处我看我可以在我的项目中使用它,看看它是否是负责任的。

其他提示

此外,看一看FrameLayout,这是相机的Gallery应用程序是如何实现缩放按钮覆盖。

如果你想给你添加自定义的覆盖屏幕上的布局,您可以创建自定义的线性布局,并获得图纸和关键事件的控制。您可以在Android布局 - 我的教程 - 覆盖 http://prasanta-paul.blogspot.com/2010 /08/overlay-on-android-layout.html

可见画廊变化知名度这是你如何得到比其他视图重叠的画廊。主样品应用程序有该技术的一些很好的例子。

周围的最简单的办法是把-40dp余量在顶部的ImageView的BUTTOM

是,这是可能的。我们面临的挑战,但是,是正确地做他们的布局。做到这一点最简单的方法是将有一个AbsoluteLayout,然后把你想让他们成为两个图像。你不需要做任何特殊的透明PNG,除了有它以后添加到布局。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top