我应该如何覆盖 VideoView 的 onDraw 以使其具有透明的圆角? [英] How should I override VideoView's onDraw in order for it to have transparent rounded corners?
问题描述
显然在 VideoView 的情况下使用背景形状不起作用此外,有很多文章如何覆盖 ImageView 的 onDraw 并使其角变圆.
但我如何为 VideoView 执行此操作?
透明圆角不能使用 VideoView
或任何 SurfaceView
来完成,根据文档:
表面是 Z 序的,因此它位于持有 SurfaceView 的窗口后面;SurfaceView 在其窗口中打孔以显示其表面.
使用 TextureView
这在理论上似乎是可能的,因为它应该表现得像一个普通视图.但是我也做不到:在父 FrameLayout
的前景中尝试了 TextureView
图层绘制和 ShapeDrawable
的 Porter Duff 模式.>
使用 VideoView
,您可以制作纯色的角.使用带有透明内容的 9-patch 和纯色的角,并设置在绘制在顶部的 ImageView
上.
检查这个 示例项目.
Clearly using a background shape doesnt work in the case of VideoView Also, there are lots of articles how to override onDraw for ImageView and make its corners round.
But how do I do it for a VideoView?
Transparent rounded corners cannot be done with a VideoView
or any SurfaceView
, as according to the documentation:
The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed.
With a TextureView
it seems theoretically possible, as its supposed to behave like a normal view. However I was unable too: Tried Porter Duff modes of both the TextureView
layer paint and a ShapeDrawable
in the foreground of the parent FrameLayout
.
With a VideoView
, what you can do is make corners of a solid color. Use a 9-patch with transparent content and just the corners of a solid color and set in on an ImageView
that gets drawn on top.
Edit: Check this example project.
这篇关于我应该如何覆盖 VideoView 的 onDraw 以使其具有透明的圆角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!