安卓:我需要一个圆形的摄像头preVIEW。如何实现呢? [英] Android: I need a circular camera preview. How to achieve it?

查看:767
本文介绍了安卓:我需要一个圆形的摄像头preVIEW。如何实现呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己需要帮助。

我想开发这个简单的应用程序,拍摄照片(哇,这就是原创!)。一切安好。我唯一​​需要的是有一个圆形的摄像头preVIEW。

I'm trying to develop this simple app that takes pictures (Wow, now that's original!). Everything is fine. The only thing I need is to have a CIRCULAR CAMERA PREVIEW.

我放在框架布局内我的相机preVIEW类(它扩展surfaceview),这是我的相机preVIEW基本。大家都知道,这是在一个矩形。因为我有更大的计划为应用程序,我需要相机preVIEW是圆形的(因此,例如,有人可以把别人的脸的照片,我可以有一些图纸左右...)。

I have my camerapreview class (which extends surfaceview) placed inside a frame layout, which is my camera preview basically. As you all know, this comes in a rectangular shape. Since I have bigger plans for the app, I'd need the camera preview to be circular (so, for example, someone can take a picture of someone's face and I can have some drawings around...).

现在,我不知道如何着手。我尝试不同的东西,创建具有XML的形状,并将其设置为背景为我的框架布局,但只是没有工作。

Now, I don't know how to proceed. I tried different things, creating a shape with xml and set it as background for my frame layout, but that just didn't work.

在花谷歌的解决方案,我决定,我不得不放弃到这里来。小时

After hours spent on google for solutions I decided that I had to give up and come here.

所以,请,如果有人知道什么,让我们知道:)我希望我是不够清楚,不要犹豫,如果需要的话,要求澄清。

So please, if someone knows anything, let us know :) I hope I was clear enough, do not hesitate to ask for clarification if needed.

推荐答案

您可以通过相机preVIEW覆盖的的ImageView 。把两个 SurfaceView 的ImageView 中的的FrameLayout 这两个 match_parent 和图像必须是在最前面。
设置在中间透明圈的黑色图像。

You can overlay an ImageView over the camera preview. put both the SurfaceView and the ImageView within a FrameLayout both match_parent and the image must be on top. Set to an black image with transparent circle in the middle.

这篇关于安卓:我需要一个圆形的摄像头preVIEW。如何实现呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆