【问题标题】:Add a Camera Preview添加相机预览
【发布时间】:2017-06-03 17:04:24
【问题描述】:

我希望我的 Activity 背景是 Camera(Back) 视图,到目前为止我已经尝试添加一个 surfaceView 但没有运气,我找到的教程是用于打开相机应用程序。 P.S- 我确实想在 SurfaceView/Camera 上添加更多资源。 & 我不想只点击图片预览 因为我没有任何代码可以显示,因为它们不是我需要的,所以这里是,尽管它可能没有必要。

【问题讨论】:

    标签: android surfaceview preview


    【解决方案1】:

    你尝试过这样的事情吗?

     <?xml version="1.0" encoding="utf-8"?>
     <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="match_parent" android:layout_height="match_parent">
    
    
          <SurfaceView
          android:layout_width="match_parent"
          android:layout_height="match_parent" />
    
       <!--views on top should come after the surfaceview, 
       at the same level    in the view heirarchy.
       this gives them a higher z-index (i.e. drawn afterwards)
       ... you could also use a RelativeLayout as the root view -->
    
          <ImageView
          android:layout_width="100dp"
          android:layout_height="100dp" 
          android:layout_gravity="center"/>
    
    
    
     </FrameLayout>
    

    【讨论】:

    • 我已经应用了代码,我会尽快通知你,并且这个简短的代码会在没有任何java类编程的情况下创建预览吗?
    • 不,抱歉,这是一个布局示例,您必须在 onCreate() 中的活动中膨胀,以便您可以将视图放在相机背景之上。表面视图需要显示从相机接收到的帧。也许本教程可能会有所帮助:blog.rhesoft.com/2015/04/02/…
    • 需要一点帮助我如何获取顶部的资源
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多