Code example for GradientDrawable

Methods: setCornerRadius

0
        super(context, attrs);
        init(); 
    } 
  
    private void init() { 
        GradientDrawable gd = new GradientDrawable();
        gd.setCornerRadius(RADIUS); 
    } 
    
    @Override 
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        mClip = new Path();
        RectF rect = new RectF(0, 0, w, h);
        mClip.addRoundRect(rect, RADIUS, RADIUS, Direction.CW);
    } 
  
    @Override 
    protected void dispatchDraw(Canvas canvas) {
        canvas.save();
        canvas.clipPath(mClip);