首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >基于surfaceView的android视图

基于surfaceView的android视图
EN

Stack Overflow用户
提问于 2017-08-05 08:09:12
回答 2查看 1.8K关注 0票数 1

我只想做一个视频呼叫布局,面对这个问题,我想为swithc相机、静音、终端呼叫和一些信息添加一些imageView和surfaceView按钮,这是我的xml。

代码语言:javascript
运行
复制
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
    >


<org.webrtc.SurfaceViewRenderer
    android:id="@+id/preview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">



<LinearLayout
    android:id="@+id/rind"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
      <!-- here my ImageView and button -->

     </LinearLayout>



</RelativeLayout>

SurfaceViewRenderer its扩展surfaceView

现在,当我运行这个程序时,我无法在surfaceView中看到我的相机,我为我的SurfaceViewRenderer添加了红色的背景,在没有相机显示的情况下,我只是搜索并找到了mySurfaceView.setZOrderOnTop(true);,我添加了它,现在它显示了相机的显示,但是我看不到我的视图(静音,结束呼叫.)

我也试着

代码语言:javascript
运行
复制
   mySurfaceView.setZOrderMediaOverlay(true);

   mySurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);

无效

我只想做这样的布局

在我使用surfaceView之前,我尝试了glsurfaceview,但是它是一样的,而且我读到了我无法在glsurfaceview中添加视图(添加窗口视图)

EN

Stack Overflow用户

发布于 2017-11-10 06:54:27

试一试,希望这能帮到你:

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<FrameLayout
    android:clipChildren="false"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<!--local view-->
<com.example.gwl.apprtc.PercentFrameLayout
    android:id="@+id/local_video_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<org.webrtc.SurfaceViewRenderer
        android:id="@+id/local_video_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
<!--remote View -->
</com.example.gwl.apprtc.PercentFrameLayout>
<com.example.gwl.apprtc.PercentFrameLayout
    android:id="@+id/remote_video_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<org.webrtc.SurfaceViewRenderer
        android:id="@+id/remote_video_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

</com.example.gwl.apprtc.PercentFrameLayout>
<!---->
</FrameLayout>
<FrameLayout
    android:id="@+id/buttons_call_container"
    android:orientation="horizontal"
    android:layout_marginBottom="@dimen/marginBottom_32dp"
    android:layout_gravity="bottom|center"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

<ImageButton
            android:id="@+id/button_call_disconnect"
            android:background="@drawable/disconnect"
            android:contentDescription="@string/disconnect_call"
            android:layout_width="@dimen/layoutWidth_48dp"
            android:layout_height="@dimen/layoutHeight_48dp"/>

<ImageButton
            android:id="@+id/button_call_toggle_mic"
            android:background="@android:drawable/ic_btn_speak_now"
            android:contentDescription="@string/toggle_mic"
            android:layout_marginRight="@dimen/marginRight_10dp"
            android:layout_width="@dimen/layoutWidth_48dp"
            android:layout_height="@dimen/layoutHeight_48dp"/>

<ImageButton
            android:id="@+id/button_call_switch_camera"
            android:background="@android:drawable/ic_menu_camera"
            android:layout_marginEnd="8dp"
            android:layout_width="48dp"
            android:layout_height="48dp"/>


</LinearLayout>

</FrameLayout>

</FrameLayout>
票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45519747

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档