我应该如何重写VideoView的OnDraw,以便它有透明的圆角? [英] How should I override VideoView's onDraw in order for it to have transparent rounded corners?

查看:6844
本文介绍了我应该如何重写VideoView的OnDraw,以便它有透明的圆角?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然,利用背景形状不工作在VideoView的情况下, 此外,还有很多文章如何重写OnDraw中的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.

但我怎么做到这一点的VideoView?

But how do I do it for a VideoView?

推荐答案

透明圆角,不能用做了 VideoView SurfaceView ,因为根据文档:

Transparent rounded corners cannot be done with a VideoView or any SurfaceView, as according to the documentation:

的表面为Z排序以便它是窗口保持其SurfaceView后面;所述SurfaceView冲头在其窗口的孔,以允许显示其表面

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.

随着 TextureView 似乎理论上是可行的,因为它应该表现得像一个普通视图。但是我无法过:无论是 TextureView 一层涂料和 ShapeDrawable 中的前景试图波特达夫模式父的FrameLayout

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.

随着 VideoView ,你可以做的是让纯色的角落。使用9补丁与透明的内容和纯色的只是角落里,并且在一个的ImageView 是被绘制在上面设置

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.

编辑:查看这个示例项目。

这篇关于我应该如何重写VideoView的OnDraw,以便它有透明的圆角?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆