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;
}
}
Wednesday, 20 May 2015
How to create CircleDrawable in Android
Subscribe to:
Post Comments (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...
-
Android ADB Commands & Tricks Android Debug Bridge (adb) is a versatile command line tool that lets you communicate with an emulator...
-
To compile Curl library for android, follow this post Here is the simple Android Example using Curl Library. Source Code: https://githu...
-
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...
No comments:
Post a Comment