Android ProgressBar

Nov 27, 2019

By default, the ProgressBar is a circular rotation.

<ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    />

NOTE: Android Show Busy/Loading and Prevent Touch (using DialogFragment) - Kotlin.

For horizontal loading animation, set

  • android:indeterminate="true"
  • style="?android:attr/progressBarStyleHorizontal" or style="@style/Widget.AppCompat.ProgressBar.Horizontal"
<ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:indeterminate="true"
    style="?android:attr/progressBarStyleHorizontal"
    />

For real horizontal progress bar

<ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:max="100"
    android:progress="50"
    style="?android:attr/progressBarStyleHorizontal"
    />
repeat(10) {    progressBar.progress = ((it+1)/10.0 * progressBar.max).toInt()}

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.