Created
December 4, 2017 14:20
-
-
Save efemoney/bae551aa488e5d9bacc156cf426f09ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LineDrawable extends Drawable { | |
private Context context; | |
private final Paint paint; | |
public LineDrawable(Context context) { | |
this.context = context; | |
paint = new Paint(); | |
paint.setStyle(Paint.Style.STROKE); | |
paint.setStrokeWidth(Utils.dpToPx(context, 1)); | |
paint.setColor(Color.parseColor("#e0e0e0")); | |
} | |
@Override | |
public void draw(Canvas canvas) { | |
Rect bounds = getBounds(); | |
canvas.save(); | |
canvas.drawLine(bounds.left, bounds.centerY(), bounds.right - bounds.left, bounds.centerY(), paint); | |
canvas.restore(); | |
} | |
@Override public void setAlpha(int i) {} | |
@Override public void setColorFilter(ColorFilter colorFilter) {} | |
@Override public int getOpacity() { return PixelFormat.OPAQUE; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment