Using android.view.SurfaceView with a camera on part of the screen

后端 未结 3 756
清酒与你
清酒与你 2020-12-08 23:54

I trying to put together an Android app that will take a picture and process it in some way. I\'d like the layout to be similar to Google Goggles. Meaning, camera preview

3条回答
  •  忘掉有多难
    2020-12-09 00:48

    First, your layout probably won't give you what you want. Consider using a RelativeLayout, with the Button anchored to the bottom, and the SurfaceView anchored to the top of the screen and the top of the Button.

    Also, you have a duplicate xmlns:android="http://schemas.android.com/apk/res/android" on your SurfaceView that you don't need. The one on your root element will suffice.

    In terms of your exception, there may be more detail in your stack trace that you are missing, explaining why startPreview() failed. Look for a "Caused by" or other line mid-way through the stack trace. If you can't identify it, edit your question and paste in the entire stack trace (and ping me via a comment on this answer, since I won't know about the edit otherwise).

    You might also experiment with this book example as another Camera preview app, to see if there's something about how I approach the problem that works better for your circumstance.

提交回复
热议问题