-3

I want to draw an arc around my textview , but I'm struggling to do it.

I'm trying to draw an Arc with canvas, transforming it on a drawable and then apply to the background of the textview. The thing is the arc isn't showing...
Here is the code to create the drawable :

 Bitmap b = Bitmap.createBitmap(500, 500, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);
    RectF rectF = new RectF(100,100,100,200);
    c.drawArc(rectF, 0 , 180, true, new Paint(Color.BLACK));
    Drawable d = new BitmapDrawable(b);

I have this(1st screenshot) and I want to do this(2nd),

What

What I Want

Community
  • 1
  • 1

1 Answers1

0

You can create custom circle drawable and then assign it to background of TextView.

Create custom drawable like below:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <stroke
        android:width="1dp"
        android:color="#00ff00"/>
</shape>

For more circular drawables options, Please view this

Firoz Memon
  • 4,282
  • 3
  • 22
  • 32
  • The thing is I can work with that but i was trying to use a canvas. Drawing an arc but then the arc didn't appear... I need an arc like a progress view that's why im asking this... – Jose Santos Aug 06 '17 at 19:20
  • try https://stackoverflow.com/questions/38657335/draw-a-text-on-a-circle-path-in-android and https://stackoverflow.com/questions/22224384/draw-text-inside-android-circle ,this might help – Firoz Memon Aug 07 '17 at 07:26