如何解决FrameLayout 项目视图在切换其可见性后丢失 z-index
我有以下布局,它引入了 webRtc 调用布局
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.activities.room.RoomActivity">
<FrameLayout
android:id="@+id/primaryFrame"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/primaryPeerCircleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="UU"
android:textAllCaps="true"
android:textSize="28sp"
android:padding="16dp"
android:textColor="@color/colorWhite"
android:background="@drawable/circle_white"
android:layout_gravity="center"/>
<org.webrtc.SurfaceViewRenderer
android:id="@+id/primaryParticipantView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone" />
<TextView
android:id="@+id/primaryParticipantText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@drawable/primary_background"
android:padding="4dp"
android:text=""
android:textColor="@color/colorWhite"
android:visibility="gone" />
<include
layout="@layout/local_peer_video"
android:layout_width="120dp"
android:layout_height="180dp"
android:layout_gravity="top|right"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<HorizontalScrollView
android:id="@+id/horizontalContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/controlsLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:id="@+id/participantsContainer"
android:layout_width="wrap_content"
android:layout_height="180dp"
android:orientation="horizontal" />
</HorizontalScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
primaryParticipantView
是全屏参与者的视频视图。
local_peer_video
是右上角的我自己的视频视图。当视频开始时,我在 local_peer_video 后面有 primaryParticipantView。当远程参与者禁用视频时,我隐藏了 primaryParticipantView 以使用 primaryPeerCircleText
显示他的名字。这可以正常工作。
val remoteParticipant = session.getRemoteParticipant(params.getString("connectionId"))
runOnUiThread {
if (params.getString("property") == "videoActive")
remoteParticipant?.videoView?.visibility = if (params.getString("newValue") == "true") View.VISIBLE else View.GONE
}
但是,当远程参与者再次启用视频时,会运行相同的代码片段并将 primaryParticipantView 的可见性设置为 VISIBLE。问题是,现在 primaryParticipantView
高于 local_peer_video,所以我看不到我自己。为什么会发生这种情况?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。