Skip to content

Instantly share code, notes, and snippets.

@efemoney
Created December 4, 2017 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save efemoney/bae551aa488e5d9bacc156cf426f09ed to your computer and use it in GitHub Desktop.
Save efemoney/bae551aa488e5d9bacc156cf426f09ed to your computer and use it in GitHub Desktop.
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