如何在android中制作圆形面具和剪辑GLSURFACHEVIEW?
我使用的SDK通过回调提供了一个矩形的如何在android中制作圆形面具和剪辑GLSURFACHEVIEW?,android,imageview,android-videoview,glsurfaceview,Android,Imageview,Android Videoview,Glsurfaceview,我使用的SDK通过回调提供了一个矩形的GLSurfaceView 我希望能够在圆形布局中渲染此视图。(即)我想在圆形视图上显示视图 当我覆盖GLSurfaceViewoverImageView 当我覆盖GLSurfaceView到VideoView时,它显示为方形 我试过下面的代码来制作圆圈GLSurfaceView public class SampleGLView extends GLSurfaceView implements View.OnTouchListener {
GLSurfaceView
我希望能够在圆形布局中渲染此视图。(即)我想在圆形视图上显示视图
- 当我覆盖
overGLSurfaceView
ImageView
- 当我覆盖
到GLSurfaceView
时,它显示为方形VideoView
GLSurfaceView
public class SampleGLView extends GLSurfaceView implements View.OnTouchListener {
private Path clippingPath;
public SampleGLView(Context context) {
this(context, null);
}
public SampleGLView(Context context, AttributeSet attrs) {
super(context, attrs);
setOnTouchListener(this);
}
private TouchListener touchListener;
@Override
public boolean onTouch(View v, MotionEvent event) {
final int actionMasked = event.getActionMasked();
if (actionMasked != MotionEvent.ACTION_DOWN) {
return false;
}
if (touchListener != null) {
touchListener.onTouch(event, v.getWidth(), v.getHeight());
}
return false;
}
public interface TouchListener {
void onTouch(MotionEvent event, int width, int height);
}
public void setTouchListener(TouchListener touchListener) {
this.touchListener = touchListener;
}
@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);
}
}
问题:
如何将其剪裁并渲染为圆形
(背景不断变化,因此我无法将透明视图覆盖在此视频视图之上。目的是使矩形glsurface视图的顶部有一个圆形glsurface视图)
有没有人知道如何解决,请评论。提前谢谢 看,看,看