This seems like it should be somewhat trivial, however in my android app, I am using canvas to draw a series of lines that are connected together. For some reason my lines are very very faint and thin. I was wondering how can I make my lines thicker? Here is my code..
for(int i=1; i<myArrayListOfValues.size(); i++){
Paint myPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
myPaint.setStrokeWidth(8/*1 /getResources().getDisplayMetrics().density*/);
myPaint.setColor(0xffff0000); //color.RED
canvas.drawLine(myArrayListOfValues.get(i), myArrayListOfValues.get(i), myArrayListOfValues.get(i-1), myArrayListOfValues.get(i-1), myPaint);
}
Another thing is..my lines and circles that I draw are ALWAYS black.. setColor() never seems to have any effect. I've tried using the color names (e.g color.red) and even their hex values (e.g 0xffff0000)
Change the value of
myPaint.setStrokeWidth(8);
to a bigger integer, for instance:
myPaint.setStrokeWidth(50);
it will make the line thicker
see also Paint.setStrokeWidth(float)
Try Including this line just after you decleare 'mypaint'
mypaint.setStyle(Paint.Style.STROKE);
What happens if you remove the ANTI_ALIAS_FLAG? Also, you should move the Paint constructor outside the for loop, so it doesn't get recreated every iteration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With