DrawRect with different fill colour?

enonod

Well-Known Member
Licensed User
Longtime User
I have scoured but not found. If I draw a rectangle it can be filled but it seems only with the same colour as the outline. If I want two rectangles adjacent, of differing colour, it would seem natural that the outline colour should be the same for both to avoid ambiguity. If I had 4 in a square I would have a motley of boundary colours.
Is there a way to have say a white outline and fill with a colour?
 

klaus

Expert
Licensed User
Longtime User
When drawing a filled rectangle it is filled with the given color, the stroke parameter has no effect.
If you want to draw a filled rectangle with a border line with a different color you must draw a filled rectangle with the fill color and then draw a none filled rectangle with the line color. Note that, if the stroke value is bigger than 1, the line is centered on the rectangle coordinates. That means that the surrounding rectangle dimensions are increased by the stroke value.

In the Android documentation I found that there are three modes for the DrawRect method STROKE, FILL and FILL_AND_STROKE (with the same color). The last one is not supprted by B4A.

Best regards.
 
Last edited:
Upvote 0

enonod

Well-Known Member
Licensed User
Longtime User
Thank you yet again Klaus, that seems like a brilliant solution, albeit time consuming.
 
Upvote 0
Top