Wednesday, July 13, 2011

[android-developers] SurfaceView#setZOrderMediaOverlay(true) not working as expected

I have a small screen camera preview being shown on top of a larger
video (see layout at the end). I use
SurfaceView#setZOrderMediaOverlay(true) on the small camera preview,
and this works most of the time. However, occasionally, the camera
preview is not fully displayed. Only the part of it not blocked by the
larger video view is displayed, while the 5dip black border *is* fully
displayed on top of the large video.

So it seems like SurfaceView#setZOrderMediaOverlay(true) is not
working as expected. My understanding of the API is that it guarantees
that the SurfaceView will be displayed on top of other SurfaceViews.

I do not want to use #setZOrderOnTop as I do want to overlap the
camera preview with some icons, and using #setZOrderOnTop(true) would
cause the camera preview to display on top of the overlay icons.

Any idea why #setZOrderMediaOverlay(true) misbehaves occasionally? I
am on Honeycomb MR1 on Motorola Xoom.

Thanks,
Shri

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">

<SurfaceView
android:id="@+id/some_video"
android:layout_width="match_parent"
android:layout_height="match_parent" />

<!-- Camera preview border -->
<RelativeLayout
android:id="@+id/camera_preview_and_overlays"
android:layout_width="100dip"
android:layout_height="50dip" >
<!-- Camera preview. #setZOrderMediaOverlay(true) will be called
for this. -->
<SurfaceView
android:id="@+id/camera_preview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/overlay_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

</RelativeLayout>
</RelativeLayout>

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment