Alright so I’ve got a weird problem here…. My goal is to draw on top of a camera preview. I’m currently doing this:
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<com.brayden.icamera.DrawingSurfaceView
android:id="@+id/drawingSurface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<SurfaceView
android:id="@+id/cameraSurface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
Drawing on the DrawingSurfaceView allows me to draw on top of the preview… At first. But. If onPause() is called and then onResume(), my drawings no longer show up on top of the preview.
Even more weird, if I do this:
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<SurfaceView
android:id="@+id/cameraSurface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<com.brayden.icamera.DrawingSurfaceView
android:id="@+id/drawingSurface"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</FrameLayout>
Flip the way they’re stacked, then when the application starts up you can’t see my drawing on top of the preview, BUT, if onPause() then onResume() is called, then my drawings start showing up. So the exact opposite behavior of the other way.
Also, this only happens on the first pause/resume cycle. So the first way, you see my drawings till you pause and resume the app, then never again. Second way, you don’t see it at first, but if you pause/resume, then from then on you’ll see the drawing. What in the hell?
It is my understanding that SurfaceViews of any kind should not overlap with other things, because the Android folks have not implemented support for that. See this thread.