如何将相机视图设置为活动背景?
在我的 Android 应用程序中,我想将相机视图显示为活动屏幕的背景。屏幕的小部件应显示在相机视图上,并且还必须可单击。我通过膨胀两个 xml 来设置活动的视图。它在活动屏幕上显示按钮。我想将活动的背景显示为相机视图,按钮(位于 xml 中)应显示在前台。请帮助我。提前致谢。
In my android app i want to show the camera view as the background of the activity screen.The widgets of the screen should display on the camera view and also must be clickable. I set the view of the activity by using the two xml by inflating them. It displays the buttons on the activity screen.I want to show the background of the activity as camera view and the buttons(which is in xml) should display on the foreground.Please help me. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 SurfaceView 可以实现这一点,为了更好地理解,请参阅 z星。
Using SurfaceView you can achieve this, for better understanding, see the source code of zxing.
看一下这里:
这里有制作显示相机预览的活动所需的所有代码。
您只需将 FrameLayour 作为 Activity 的基本布局即可。然后添加一个带有注册的 SurfaceHolder.Callback 处理程序的 SurfaceView,以在其上绘制预览。最后添加您需要的布局或小部件,通过 FrameLayout 服务在其之上构建您自己的布局。
Take a look here:
There is all the code you need to make an activity which shows the camera preview.
You simply need to put a FrameLayour as the base layout of your activity. Then add a SurfaceView with a registred SurfaceHolder.Callback handler to draw your preview on it. Finally add whichever layout or widget you need to build your own layout above itthrough the FrameLayout services.