hi, i have a circular progress bar that has a thumb, i would want the percentage text to be written inside the thumb.
Here is what i have tried
What I have tried:
this updates the progress value(thumb sweep ) on the circular bar
private void updateProgress(int progress, bool fromUser)
{
if (progress == INVALID_PROGRESS_VALUE)
{
return;
}
progress = (progress > mMax) ? mMax : progress;
progress = (progress < 0) ? 0 : progress;
mProgress = progress;
if (mOnSeekArcChangeListener != null)
{
mOnSeekArcChangeListener.onProgressChanged(this, progress, fromUser);
}
mProgressSweep = (float)progress / mMax * mSweepAngle;
updateThumbPosition();
Invalidate();
}
this updates the thumb position.
private void updateThumbPosition()
{
int thumbAngle = (int)(mStartAngle + mProgressSweep + mRotation + 90);
mThumbXPos = (int)(mArcRadius * Math.Cos(ToRadian(thumbAngle)));
mThumbYPos = (int)(mArcRadius * Math.Sin(ToRadian(thumbAngle)));
}
those are working fine
here is where my issue lie.
public void setProgressBar(int progress, Context context, SeekArc defkk)
{
Drawable d = ContextCompat.GetDrawable(context, Resource.Drawable.seek_arc_control_selector);
Canvas c = new Canvas();
Bitmap bitmap = Bitmap.CreateBitmap(d.IntrinsicWidth, d.IntrinsicHeight, Bitmap.Config.Argb8888);
c.SetBitmap(bitmap);
d.SetBounds(0, 0, d.IntrinsicWidth, d.IntrinsicHeight);
d.Draw(c);
string text = progress.ToString() + "%";
Paint p = new Paint();
p.SetTypeface(Typeface.CreateFromAsset(context.Assets, "fonts/Brandon_bld.otf"));
p.TextSize = 18;
p.Color = Color.White;
int thumbAngle = (int)(mStartAngle + mProgressSweep + mRotation + 90);
int width = (int)p.MeasureText(text);
int yPos = (int)((c.Height / 2) - ((p.Descent() + p.Ascent()) / 2));
c.DrawText(text, (bitmap.Width - width) / 2, yPos, p);
defkk.SetThumb(new BitmapDrawable(Resources, bitmap));
}
i need to insert the code in the function above in updateProgress. so that as the progress updates, it inserts the text.