Как сделать круг GLSurfaceView на Videoview? - PullRequest
1 голос
/ 09 января 2020

Я использую библиотеку камеры для записи видео, она использует GLSurfaceView. В моем макете на VideoView я накладываю GLSurfaceView.

Он показывает форму круга, когда я накладываю GLSurfaceView поверх ImageView

Он показывает квадратную форму, когда я накладываю GLSurfaceView поверх VideoView .

Я попробовал приведенный ниже код для создания круга GLSurfaceView.

publi c Класс SampleGLView расширяет GLSurfaceView и реализует 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);
} }

У кого-нибудь есть идеи, как ее решить.

...