【问题标题】:How to using android's camera surfaceView and overlaying view in Fragment?如何在 Fragment 中使用 android 的相机 surfaceView 和覆盖视图?
【发布时间】:2014-12-09 08:18:31
【问题描述】:

在我的应用程序中,我想使用surfaceview 来显示来自相机的PreView,并在视图上显示一些提示。我不需要存储图像。我想使用 FragmentActivity 来实现这一点。我是新手,可以给我教程吗?谢谢~

【问题讨论】:

    标签: android android-camera surfaceview android-fragmentactivity


    【解决方案1】:

    试试这个 xml。它包含 2 个容器,一个用于相机预览,另一个用于提示,其背景需要不可见以显示 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:orientation="vertical">
    <LinearLayout
        android:id="@+id/camera_preview_linear_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <SurfaceView
            android:id="@+id/camera_preview_surface_view"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="match_parent">
        </SurfaceView>    
        <Button
            android:id="@+id/camera_takepicture_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Take picture">
    </LinearLayout>
    <LinearLayout
        android:id="@+id/camera_preview_hints"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#00000000"
        android:orientation="vertical"> 
        <!-- Your hint goes here-->
    </LinearLayout>
    </FrameLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      • 2011-07-04
      • 1970-01-01
      相关资源
      最近更新 更多