Reputation: 81
hey guys i want to put stroke in this code, but when i use the setStroke its not working. Can you help me to how to put stroke in this code.thank for any help, im newbie in android. I was trying to do this, put a white stroke on the gray box. How can I achieve this?
private static class Nub extends View {
private Paint paint = new Paint();
private Path path = new Path();
public Nub( Context context ) {
super( context );
paint.setStyle( Paint.Style.FILL );
paint.setColor( 0xFF313231 );
paint.setAntiAlias( true );
path.lineTo( getDIP( context, 20 ), 0 );
path.lineTo( getDIP( context, 10 ), getDIP( context, 15 ) );
path.close();
}
Upvotes: 0
Views: 228
Reputation: 4249
There is no such method setStroke()
on Paint
. Where are you trying to call setStroke()
?
What I believe you want is
paint.setStyle(Paint.Style.STROKE);
paint.setColor(0xFFFFFFFF); // should probably use a color resource here instead of hard coding
paint.setStrokeWidth(3); // you should probably do some px to dp conversion here
You will also have to add a call to
canvas.drawPath(path,paint);
once you have plotted out your path.
Upvotes: 1