title: Custom view to mask a parent and make transparent circle at center of parent
body: <p>I want to make a circular suface view (porthole effect). Surface view is inside a Frame layout. I want to make a custom view that i can add to Frame layout on top of surface view and mask whole Frame layout to produce porthole effect so that surface view will be shown as circle.</p>
  
  <p>I searched and a lot for answer on Web and Stackoverflow but failed.
  Then i saw <a href="https://stackoverflow.com/questions/36763696/how-to-create-a-transparent-circle-inside-rectangle-shape-in-xml-in-android/36764393#36764393">this</a> question and i tried this custom view to mask frame layout(and hence surfaceview) but i am not getting the desired result.</p>
  
  <p>What i want is a custom view that can take height and width of it's parent (parent is square in shape) and make a transparent circle at it's center touching  all four sides at middle of the boundaries, rest(view - circle) of the view will be of color that i can set.</p>
  
  <pre><code>public class FocusView extends View {
  
  private Paint mTransparentPaint;
  private Paint mSemiBlackPaint;
  private Path mPath = new Path();
  
  public static float radius , xCor , yCor;
  
  public FocusView(Context context) {
      super(context);
      initPaints();
  }
  
  public FocusView(Context context, AttributeSet attrs) {
      super(context, attrs);
      initPaints();
  }
  
  public FocusView(Context context, AttributeSet attrs, int defStyleAttr) {
      super(context, attrs, defStyleAttr);
      initPaints();
  }
  
  private void initPaints() {
      mTransparentPaint = new Paint();
      mTransparentPaint.setColor(Color.GREEN);
      mTransparentPaint.setStrokeWidth(10);
  
      mSemiBlackPaint = new Paint();
      mSemiBlackPaint.setColor(Color.TRANSPARENT);
      mSemiBlackPaint.setStrokeWidth(10);
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
  
      mPath.reset();
  
      mPath.addCircle(xCor,yCor,radius, Path.Direction.CW);
      mPath.setFillType(Path.FillType.INVERSE_EVEN_ODD);
  
      canvas.drawCircle(xCor,yCor,radius, mTransparentPaint);
  
      canvas.drawPath(mPath, mSemiBlackPaint);
      canvas.clipPath(mPath);
      canvas.drawColor(Color.parseColor("#FFFFFF"));        //A6000000
  }
  
  }
  </code></pre>
  
  <p>Please if somebody can help me. Thanks in advance.</p>