我已经在stackoverflow和其他网站上看过很多类似的问题,但都没有找到解决方案。我只是想在SurfaceView上叠加一个透明视图,最后在上面绘制一个矩形,使其覆盖相机预览。
我无法让自定义视图变为透明,它会遮挡住底层的相机预览。有什么建议吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<FrameLayout
android:layout_alignParentTop="true"
android:layout_width="fill_parent"
android:layout_height="400dip">
<SurfaceView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/drawSurface" />
<com.bobby.facecapture.FaceOverlayView
android:id="@+id/drawOverlay"
android:background="@android:color/transparent"
android:layout_width="200dip"
android:layout_height="200dip"
/>
</FrameLayout>
</RelativeLayout>
这里的200x200只是暂时的,目的是为了证明它确实覆盖在其他视图之上。
FaceOverlayView只是一个自定义视图 - 直接从View派生而来,现在没有重写任何内容。
我在相机预览的顶部得到了一个黑色矩形。
onDraw
方法并且什么都不做(不要调用super
),这样有改善吗? - Ertebolle