- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想在 Camera SurfaceView\preview 上看到一张图片。我怎么做?有例子吗?
最佳答案
可以在 ZXing 中找到一个很好的例子图书馆,Barcode Scanner申请。
他们所做的是为 SurfaceView
和他们的自定义 ViewfinderView
使用 FrameLayout
以便 SurfaceView
和 ViewfinderView
覆盖全屏:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<SurfaceView android:id="@+id/preview_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerInParent="true"/>
<com.google.zxing.client.android.ViewfinderView
android:id="@+id/viewfinder_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/transparent"/>
</FrameLayout>
请注意两个 View 的 layout_height
和 layout_width
中的 fill_parent
值。
然后他们在 ViewfinderView.onDraw()
中绘制定制的东西方法,就在相机预览显示的内容之上。
如果您不想绘制任何东西,而只想使用预定义的图像,则使用 ImageView
而不是 ViewfinderView
。您可能会考虑调用 setAlpha
方法来使您的图像透明(如果可绘制对象本身还不是透明的)。
这是条形码扫描器的屏幕截图:
关于android - 上面有透明图像的相机预览,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6181165/
我认为这应该不是一个大问题,但我自己找不到解决方案。一如既往:p 我有一个 UIWebView,其背景颜色设置为clearColor,但是当我尝试向下滚动太多时,我会在加载的 HTML 上方看到深灰色
我注意到,每当我重新安装我的应用程序时,IdentifierForVendor 都会不断变化。有没有办法让我的设备拥有相同的标识符?问题是,我需要确保标识符相同,因为我有一个备份系统,即使在删除并重新
一切都在标题中。 我有一个带有单元格的 UITableView。 cells 有一个Shadow (self.layer.shadow...)。 问题是一个单元格的阴影重叠上方的单元格。我怎样才能防止
我正在尝试创建一个切换开关,您可以在其中点击一侧,然后背景会滑过以使该侧“处于事件状态”。 为了适应可变宽度,我使用 display: table 设置了切换的两侧。这很好用。然后,我将第三个 div
我是一名优秀的程序员,十分优秀!