我使用的 SDK 通过回调提供矩形 glsurfaceview。
我希望能够以圆形布局渲染此视图。 (即)我想在圆形视图上显示视图
我尝试过使用屏蔽布局,例如使用可屏蔽布局https://github.com/christophesmet/android_maskable_layout https://github.com/christophesmet/android_maskable_layout(对于图像效果很好,对于视频效果不太好)
我该如何将其剪切并渲染为圆形?
(背景不断变化,所以我无法在此视频视图之上叠加透明视图。目的是获得一个矩形 glsurface 视图,其顶部有一个圆形 glsurface 视图)
**UI Objective : **
我现在对一个项目有几乎相同的要求,其中涉及屏蔽由PexKit https://github.com/pexip/pexkit-sdk。对我有用的解决方案是创建 FrameLayout (或任何其他 ViewGroup)的子类并将 GLSurfaceView 放入其中。
然后在FrameLayout子类中使用canvas.clipPath:
private Path clippingPath;
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
if (w != oldw || h != oldh) {
int radius = Math.min(w, h)/2;
clippingPath = new Path();
clippingPath.addCircle(w/2, h/2, radius, Path.Direction.CW);
}
}
@Override
protected void dispatchDraw(Canvas canvas) {
int count = canvas.save();
canvas.clipPath(clippingPath);
super.dispatchDraw(canvas);
canvas.restoreToCount(count);
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)