1

I'm using the material library's LinearProgressIndicator for a horizontal progress bar.

How would I add a label inside the indicator of the progressbar indicator?

enter image description here

<com.google.android.material.progressindicator.LinearProgressIndicator
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="65"
        app:trackColor="@color/background_color"
        app:trackThickness="16dp"
        app:indicatorColor="@color/black"/>
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83
  • Have you considered putting a textview on top of it? Of course only if the height of the indicator view is high enough. Or you look for something else in particular? – Kozmotronik Dec 12 '22 at 06:32
  • I want it to be inside and following the left side of the indicator. I am aware there is a few libraries to do so, but I am wondering if there can be a simple solution (like an xml flag) instead of using an entire library for this problem. – DIRTY DAVE Dec 12 '22 at 08:43
  • By *I want it to be inside and following the left side of the indicator.* you mean that you want it to follow the indicator and it moves toward right as the indicator moves to completion? Or just want it to be static at the center only? – Kozmotronik Dec 12 '22 at 08:57
  • Yup, following the indicator – DIRTY DAVE Dec 12 '22 at 08:57
  • 1
    Aha I see, unfortunately there is no built-in API that can do something like this. But you can do some tricks such as putting a textview on top, moving the textview towards right by applying the progress value as an offset from the start of the textiew. This way the textview will slide towards right as the indicator value increments. You can even animate this movement but I'm not sure whether the animation can be fast enough to catch progress changes. – Kozmotronik Dec 12 '22 at 09:06
  • Oh okay. Seems like too much trouble to program. I think I will just use one of the libraries I found. Thanks. – DIRTY DAVE Dec 12 '22 at 09:09

1 Answers1

0

Take a look at the ProgressView library. I think it is what you are looking for.

enter image description here

C.F.G
  • 817
  • 8
  • 16