android - Monodroid - 绘制叠加层并在相机预览上放置一个按钮

标签 android xamarin.android

从这个示例开始:https://github.com/xamarin/monodroid-samples/blob/master/ApiDemo/Graphics/CameraPreview.cs

如何在预览中添加取景器(只是一个矩形)和按钮?

谢谢!

最佳答案

您可以像这样使用 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 中是一种将 View 简单地堆叠在 SurfaceView 之上的方法。使用类似的方法添加取景器。

关于android - Monodroid - 绘制叠加层并在相机预览上放置一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8829991/

相关文章:

android - 从 Android 应用程序的网站数据库验证登录页面

android - 此 Android 代码的 MonoDroid 等价物是什么

xamarin - 如何在 Xamarin.Forms 中更改 Android 应用程序名称?

java - Android Studio : Items in RecycleView "jumps" to the left

java - 如何阻止 Android 应用程序旋转?

android - 弹出自定义键盘中按下的键

xamarin - 这个项目需要迁移xamarin项目

xamarin.forms - 如何以Xamarin形式获取设备ID?

c# - Xamarin Forms - 导航栏中带有 SearchBar 的 ContentPage

android - StatementWithEmptyBody 的目的是什么?