11

I've used "android.material.progressindicator" for the purpose of showing progress in horizontal view but I can't hear my XML

<com.google.android.material.progressindicator.ProgressIndicator
                android:background="@color/grey"
                android:id="@+id/progressInd"
                style="@style/Widget.MaterialComponents.ProgressIndicator.Linear.Determinate"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:indeterminate="false"
                android:max="100"
                android:progress="30"
                android:progressDrawable="@drawable/bidding_progress" />

enter image description here

RaJ
  • 775
  • 2
  • 8
  • 21

1 Answers1

19

You can use:

<com.google.android.material.progressindicator.LinearProgressIndicator
    app:indicatorColor="?attr/colorPrimary"
    app:trackColor="@color/..."
    />

Use progressIndicator.setProgressCompat((int) value, true); to update the value in the indicator.

Use the attributes:

  • indicatorColor to se the color of the color of indicator
  • trackColor to set the color of track
  • trackThickness to set the height of the progress bar

enter image description here

Note: It requires at least the version 1.3.0-alpha04

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • In SDK Version 25 I run that application. App crash. Logcat message following as "Before Android 4.1, method android.graphics.drawable.Drawable com.google.android.material.progressindicator.ProgressIndicator.getCurrentDrawable() would have incorrectly overridden the package-private method in android.widget.ProgressBar" but this code runs on SDK 28. Please give me your suggestions to slove this issue. – RaJ Jul 22 '20 at 13:36
  • @RaJ you can file an issue on the [github repo](https://github.com/material-components/material-components-android). – Gabriele Mariotti Jul 22 '20 at 13:39
  • Ok thanks. Initially, I've set progressIndicator.setMin(0); now I remove that line now working fine. – RaJ Jul 22 '20 at 13:43
  • For indetermined: ` android:indeterminate="true"` – mathematics-and-caffeine Oct 13 '21 at 14:14