Obviously, it is never recommended that you have code in your application that you don’t understand, so I won’t just write a bunch of equations in Java code for you. If, however, you follow and understand the math below, then it will be relatively simple for you to use the described equations in your code and draw an arc.
To get the rounded tip of the pointer, you need to change updatePointerPath() .
For now, it just uses rLineTo () to draw the three lines that make up the triangle.
There is another method in the android Path class called arcTo() , which takes the form:
arcTo(RectF oval, float startAngle, float sweepAngle)
You can use this method to draw your arc at the end of the pointer, but first you need to work out a few things.
You can already calculate the coordinates of the three corners of the pointer triangle. This is what updatePointerPath() already does. Now take a look at the chart below. To use arcTo() , you will need to calculate the following:
- The coordinates of point T where your arc begins.
- Coordinates of the upper left and lower right corners of the bounding RectF
- Your starting angle (
) - Sweep Angle (2 *
)

Starting angle
can be easily found using the base trigger, as shown in the diagram below.

Note. . It is best if you use Radians instead of Degrees for all angles, as this is what all the trigger functions in the android 'Math' class require. With that in mind:
- There are 2
Radians in a circle - Three angles in a triangle make up
Radians - Right angle
/ 2 Radians
So, adding three triangles to the triangle formed by points C , T and P , you get:
+
+
/ 2 = 
therefore
=
/ 2 - 
So now we have calculated
and
.
Next, d is the distance between point P and the bottom border of the frame.
You can get it by calculating the distance from point C to point P , and then subtracting the radius r .
Now:
sin (
) = r / (distance from C to P )
Consequently:
distance from C to P = r / sin (
)
And therefore, given that the distance d is the distance from point C to point P minus the radius r , we obtain:
d = ( r / sin (
)) - r
This gives you all the information you need to calculate the coordinates of the upper left and lower right corners of the bounding RectF.
Now all that remains is to work out the coordinates of the point T.
First determine the distance from P to T.
Given that:
tan (
) = r / (distance from P to T )
We get:
distance from P to T = r / tan (
)
Finally, adding another point to the chart ....

We can see that:
sin (
) = (distance from P to A ) / (distance from P to T )
So:
distance from P to A = (distance from P to T ) * sin (
)
Similarly:
cos (
) = (distance from T to A ) / (distance from P to T )
So:
distance from T to A = (distance from P to T ) * cos (
)
Using this information, you can calculate the coordinates of the point T !
If you all understand this, then coding is easy. If you don’t know anything, just ask.
Below is an idea of what an updated updatePointerPath() might look like.
private void updatePointerPath() { float xDistance; float yDistance; mPointer = new Path(); mPointer.setFillType(Path.FillType.EVEN_ODD);