如何使framelayout for Video与Agora具有圆角?

发布于 2025-01-26 11:18:09 字数 1740 浏览 3 评论 0原文

目前,我尝试过,但没有起作用。

val surfaceView = RtcEngine.CreateRendererView(baseContext)
        surfaceView.apply {
            clipToOutline = true
            clipBounds = Rect(15,15, 15, 15)
            outlineProvider = CircularOutlineProvider(15)
            setZOrderMediaOverlay(true)
        }
        binding.localVideoViewContainer.apply {
            addView(surfaceView)
            clipToOutline = true
            clipBounds = Rect(15,15, 15, 15)
            outlineProvider = CircularOutlineProvider(15)
        }
class CircularOutlineProvider(val c: Int):ViewOutlineProvider() {
  override fun getOutline(view:View, outline:Outline) {
    outline.setRoundRect(c, c, view.width - c, view.height - c, view.width/2f)
  }
}
<FrameLayout
    android:id="@+id/local_video_view_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="true"
    android:clipToOutline="true"
    tools:background="@color/gray_7f"/>

我什至尝试使用类似的可绘制文件设置背景,但不起作用。

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#CCCCCC"/>    

    <stroke android:width="2dp"
        android:color="#999999"/>

    <padding android:left="2dp"
         android:top="2dp"
         android:right="2dp"
         android:bottom="2dp"/> 

    <corners android:radius="8dp" />
</shape>
<FrameLayout
    android:width="match_parent"
    android:height="wrap_content"
    android:background="@drawable/rounded_shape"/>

另外,WebView也有类似的问题。这是相关的吗?

At the moment, I tried with this but didn't work.

val surfaceView = RtcEngine.CreateRendererView(baseContext)
        surfaceView.apply {
            clipToOutline = true
            clipBounds = Rect(15,15, 15, 15)
            outlineProvider = CircularOutlineProvider(15)
            setZOrderMediaOverlay(true)
        }
        binding.localVideoViewContainer.apply {
            addView(surfaceView)
            clipToOutline = true
            clipBounds = Rect(15,15, 15, 15)
            outlineProvider = CircularOutlineProvider(15)
        }
class CircularOutlineProvider(val c: Int):ViewOutlineProvider() {
  override fun getOutline(view:View, outline:Outline) {
    outline.setRoundRect(c, c, view.width - c, view.height - c, view.width/2f)
  }
}
<FrameLayout
    android:id="@+id/local_video_view_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="true"
    android:clipToOutline="true"
    tools:background="@color/gray_7f"/>

I even tried with setting background with drawable file like this, but didn't work.

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"> 
    <solid android:color="#CCCCCC"/>    

    <stroke android:width="2dp"
        android:color="#999999"/>

    <padding android:left="2dp"
         android:top="2dp"
         android:right="2dp"
         android:bottom="2dp"/> 

    <corners android:radius="8dp" />
</shape>
<FrameLayout
    android:width="match_parent"
    android:height="wrap_content"
    android:background="@drawable/rounded_shape"/>

plus, WebView also has similar issue. Is that related?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

誰ツ都不明白 2025-02-02 11:18:09

它是相关的,一些视频(SurfaceView)和Web内容(WebView)在本机侧“在”框架下“在本机”框架上呈现,而又不尊重其布局。这些视图 s实际上是在将其定位的位置中的布局中“切开一个孔”,并且无论其他框架级别 view S或与框架相关的装饰,本机侧正在覆盖此问题,

您可以尝试使用textureView在您的播放器中,就像surfaceview的V2一样,其尊重(部分)框架绘制的参数和XML属性,这是用于Shure的,因此也许也可以覆盖它

it is related, some videos (SurfaceView) and web content (WebView) are rendered on native side "under" framework without respecting its layout. these Views are in fact "cutting a hole" in layout in place where they are positioned and some smart alghorithms are drawing on these rectangles no matter of other framework-level Views or framework-related decorations, native side is overwriting this

you can try to use TextureView if possible with your player, its like v2 of SurfaceView, its respecting (partially) framework drawn params and XML attributes, thats for shure, so maybe also drawables/Views covering it

凡间太子 2025-02-02 11:18:09

使用cardView代替framelayout并设置了转角半径,然后将Agora中的远程图表View添加到它。

<androidx.cardview.widget.CardView
                android:id="@+id/small_video_container"
                android:layout_width="134dp"
                android:layout_height="134dp"
                app:cardCornerRadius="70dp"
                app:cardBackgroundColor="@android:color/transparent"
                android:layout_gravity="center"/>

Use a CardView instead of FrameLayout and set corner radius, then add remoteSurfaceView from agora to it.

<androidx.cardview.widget.CardView
                android:id="@+id/small_video_container"
                android:layout_width="134dp"
                android:layout_height="134dp"
                app:cardCornerRadius="70dp"
                app:cardBackgroundColor="@android:color/transparent"
                android:layout_gravity="center"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文