Reputation: 6819
Starting with this sample: 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?
Thanks!
Upvotes: 1
Views: 2870
Reputation: 33751
You could use a FrameLayout
like this:
<?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>
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.
Upvotes: 3