问题
I am drawing several circles with transparency. The number of circles and their positions are not fixed. Currently I am setting the transparent color in a Paint
object and drawing the circles in a for loop with the Canvas
object. But that causes overlapping.
I have thought of a method: - Render all the circles as opaque on something other than the main canvas. - Set the transparency. - Draw the final object on canvas.
How do i implement that on android?
回答1:
Create a new bitmap with ARGB888, and draw on it's canvas all your shapes with no transparency. Then draw the new bitmap into the main canvas using a Paint on which you called setAlpha earlier
来源:https://stackoverflow.com/questions/10942590/drawing-translucent-shapes-without-overlapping