Monodroid - 绘制叠加层并在相机预览上放置一个按钮 [英] Monodroid - Draw an overlay and put a button over a camera preview
本文介绍了Monodroid - 绘制叠加层并在相机预览上放置一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从这个示例开始:https://github.com/xamarin/monodroid-samples/blob/master/ApiDemo/Graphics/CameraPreview.cs
如何在预览中添加取景器(只是一个矩形)和一个按钮?
How would I add a view finder (just a rectangle) and a button to the preview?
谢谢!
推荐答案
你可以像这样使用 FrameLayout
:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.view.SurfaceView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.view.SurfaceView>
<RelativeLayout android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#FFFFFF" android:layout_alignParentBottom="true">
<ImageView android:scaleType="centerCrop" android:src="@drawable/some_drawable" android:layout_centerInParent="true" android:clickable="true"
android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/my_button"/>
</RelativeLayout>
</FrameLayout>
将所有内容包装在 FrameLayout
中是一种将视图简单地堆叠在 SurfaceView
之上的方法.使用类似的方法添加取景器.
Wrapping everything in the FrameLayout
is one way to simply stack views on top of the SurfaceView
. Use a similar approach to add your viewfinder.
这篇关于Monodroid - 绘制叠加层并在相机预览上放置一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文