Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android中制作圆形面具和剪辑GLSURFACHEVIEW?_Android_Imageview_Android Videoview_Glsurfaceview - Fatal编程技术网

如何在android中制作圆形面具和剪辑GLSURFACHEVIEW?

如何在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 {

我使用的SDK通过回调提供了一个矩形的
GLSurfaceView

我希望能够在圆形布局中渲染此视图。(即)我想在圆形视图上显示视图

  • 当我覆盖
    GLSurfaceView
    over
    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视图)

有没有人知道如何解决,请评论。提前谢谢

看,看,看