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;
}
}
Showing posts with label android custom view. Show all posts
Showing posts with label android custom view. Show all posts
Wednesday, 20 May 2015
How to create CircleDrawable in Android
Subscribe to:
Posts (Atom)
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...
-
Things after Kotlin Android Extensions(KTX) I remembered in MVVM when I have to declare ViewModel, I initialize View Model like this. p...
-
1. Download the source code of curl library http://curl.haxx.se/download.html 2.Create a file build_andorid.sh and copy below content...
-
Hi, Source Code Link: https://github.com/JohnnyIqbal/ContactSyncBG Please add appcomapt library to run this project. This is Contac...