问题
I'm using camera recorder library for video recording it's use GLSurfaceView. In my layout on VideoView I overlay GLSurfaceView.
It's showing Circle shape when I overlay GLSurfaceView over ImageView
It's showing Square shape when I overlay GLSurfaceView over VideoView.
I have tried below code for making circle 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); } }
Is any one have idea how to solve it.
来源:https://stackoverflow.com/questions/59660335/how-can-i-make-circle-glsurfaceview-on-videoview