Android Question Semi-circle with rounded "tip" - Inline java or Javaobject could be enough?


Licensed User
Longtime User

I found examples (here on on how to draw an empty arc but they use path and clips; I don't think I can apply a Java Paint object to them, thanks to which I could use StrokeCap to get the rounded tip.

For that image (I don't need the gradiend, although...!):
Last edited:


B4X founder
Staff member
Licensed User
Longtime User

Sub Globals
    Private ImageView1 As B4XView
    Private BC As BitmapCreator
    Private Gradient As BCBrush
    Private xui As XUI
End Sub

Sub Activity_Create(FirstTime As Boolean)
    BC.Initialize(ImageView1.Width, ImageView1.Height)
    Dim gbc As BitmapCreator
    gbc.Initialize(BC.mWidth, BC.mHeight)
    gbc.FillGradient(Array As Int(xui.Color_Green, xui.Color_Blue), gbc.TargetRect, "TL_BR")
    Gradient = gbc.CreateBrushFromBitmapCreator(gbc)
End Sub

Sub Activity_Click
    Draw(Rnd(0, 360))
End Sub

Sub Draw (Degree As Float)
    BC.DrawRect(BC.TargetRect, xui.Color_Transparent, True, 0)
    Dim center As Float = BC.mWidth / 2
    Dim r As Float = center - 2
    Dim stroke As Float = 20dip
    BC.DrawCircle(center, center, r, 0xFFDDDDDD, False, stroke)
    BC.DrawArc2(center, center, r, Gradient, False, stroke, -90, Degree)
    Dim y As Float = center - CosD(Degree) * (r - stroke / 2)
    Dim x As Float = center + SinD(Degree) * (r - stroke / 2)
    BC.DrawCircle2(center, center - r + stroke / 2, stroke / 2, Gradient, True, 0)
    BC.DrawCircle2(x, y, stroke / 2, Gradient, True, 0)
    BC.SetBitmapToImageView(BC.Bitmap, ImageView1)
End Sub

There is an assumption here that the ImageView is square.
Upvote 0


Licensed User
Longtime User
Now "remember" something.

Months ago I published (and removed? I can't find it now!) source code to draw lines with rounded end or rounded start.

The simple "trick" I had thought of was only to draw a circle at the end or beginning of the line - semicircle, since I was drawing it "a ray back".

The question was that at the time I wanted to draw an "animated" rectangle, that is not all in one step, with rounded corners, using that "technique"; I should have drawn many circles - just like pixels, but the problem was how to follow the curved corners!

So I abandoned that idea and thought about the circle.

While the source I published is about a couple of months ago ( I probably removed it), the issue is... slightly older....

august, 2014 !!! :(

more recent:

(please, read this post just for curiosity; I will use rounded images, now)
Last edited:
Upvote 0