我只想制作一个视频通话布局,我遇到了这个问题 我想在surfaceView上添加一些imageView和按钮,用于swithc相机,静音,结束通话和一些信息,这是我的xml
<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,它扩展了surfaceView
现在当我运行这个我无法在SurfaceView中看到我的相机并且我为我的SurfaceViewRenderer添加红色背景并且它出现时没有我的相机显示我只是搜索并且我发现mySurfaceView.setZOrderOnTop(true);
我添加它现在它显示显示相机,但我看不到我的观点(静音,结束通话......)
我也试试
mySurfaceView.setZOrderMediaOverlay(true);
mySurfaceView.getHolder().setFormat(PixelFormat.TRANSPARENT);
没效果
我只想制作像这样的布局
在我使用surfaceView
之前,我试过了glsurfaceview
,但同样的,并且我在glsurfaceview中看到了我无法做到这一点(在glsurfaceview上添加视图)
答案 0 :(得分:0)
试试这个希望这会对你有所帮助:
<?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>
答案 1 :(得分:0)
尝试此希望对您有帮助
并为最上面的界面设置setZOrderMediaOverlay(true)和setZOrderMediaOverlay(false)作为下一个界面
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context="com.discuss.app.call.CallScreen" android:id="@+id/backgroundImage" android:background="@color/black" android:windowSoftInputMode="stateHidden">
<LinearLayout android:layout_width="wrap_content" android:id="@+id/remoteVideoContainer" android:layout_height="wrap_content" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent" android:background="@color/black">
<org.webrtc.SurfaceViewRenderer android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/remoteVideoViewSurface" android:visibility="gone" android:backgroundTint="@color/darkBackgroundColor" />
</LinearLayout>
<LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" app:layout_constraintEnd_toStartOf="parent" app:layout_constraintStart_toEndOf="parent" app:layout_constraintBottom_toTopOf="parent" app:layout_constraintTop_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.284" app:layout_constraintVertical_bias="0.492" android:id="@+id/localVideoContainer" android:elevation="7dp" android:background="@color/black">
<org.webrtc.SurfaceViewRenderer android:layout_width="100dp" android:layout_height="100dp" android:id="@+id/localVideoViewSurface" android:visibility="gone" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>