Showing posts with label circledrawable. Show all posts
Showing posts with label circledrawable. Show all posts

Wednesday, 20 May 2015

How to create CircleDrawable in Android

 public class CircleDrawable extends Drawable { 
   float width; 
   float height; 
   Paint mPaint; 
   RectF mRectf; 
   Paint mPaintR; 
   public CircleDrawable(float width, float height, int color) { 
     this.width = width; 
     this.height = height; 
     mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 
     mPaint.setColor(color); 
     mPaint.setStyle(Paint.Style.FILL); 
     mPaintR = new Paint(Paint.ANTI_ALIAS_FLAG); 
     mPaintR.setColor(Color.RED); 
     mPaintR.setStyle(Paint.Style.STROKE); 
     mPaintR.setStrokeWidth(10f); 
     mRectf = new RectF(0, 0, width, height); 
     // mRectf.offset((getMinimumWidth() - width) / 2, (getMinimumHeight() - height) / 2); 
   } 
   @Override 
   public void draw(Canvas canvas) { 
     // canvas.drawRect(mRectf, mPaintR); 
     canvas.drawCircle(mRectf.centerX(), mRectf.centerY(), width / 2, mPaint); 
   } 
   @Override 
   public void setAlpha(int alpha) { 
   } 
   @Override 
   public void setColorFilter(ColorFilter cf) { 
   } 
   @Override 
   public int getOpacity() { 
     return 0; 
   } 
 } 

Things after Kotlin Android Extensions

Things after Kotlin Android Extensions(KTX) I remembered in MVVM when I have to declare ViewModel, I initialize View Model like this. p...