如何使framelayout for Video与Agora具有圆角?
目前,我尝试过,但没有起作用。
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它是相关的,一些视频(
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. theseView
s 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-levelView
s or framework-related decorations, native side is overwriting thisyou can try to use
TextureView
if possible with your player, its like v2 ofSurfaceView
, its respecting (partially) framework drawn params and XML attributes, thats for shure, so maybe also drawables/View
s covering it使用cardView代替framelayout并设置了转角半径,然后将Agora中的远程图表View添加到它。
Use a CardView instead of FrameLayout and set corner radius, then add remoteSurfaceView from agora to it.