
Determinate horizontal progress bar with animated fills and snake/line styles, customizable colors, line width, tip indicator and animation duration; usable in XML or Compose UIs.
Animated determinate horizontal progress bar for Android Views and Compose on Android, iOS, and desktop.
Add the View artifact to your app module. It supports API 14 and up and has no Compose dependencies.
dependencies {
implementation 'io.github.mckrpk:AnimatedProgressBar:1.2.0'
}Add the Compose artifact to your Compose-enabled app module. Gradle selects the Android variant automatically. It supports API 21 and up.
dependencies {
implementation 'io.github.mckrpk:AnimatedProgressBar-compose:1.2.0'
}Add the same artifact to commonMain of your Compose Multiplatform module. It supports Android, iOS (iosArm64, iosSimulatorArm64, iosX64), and desktop JVM.
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.mckrpk:AnimatedProgressBar-compose:1.2.0")
}
}
}Add the View to your layout. If the root already declares the app namespace, reuse it. The color resources below are examples from the Android sample. Supply your own resources or omit the color attributes to use the defaults.
<com.mckrpk.animatedprogressbar.AnimatedProgressBar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/animatedProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:animationDurationInMs="1600"
app:animationStyle="snake"
app:lineWidth="6dp"
app:max="1000"
app:progress="750"
app:progressColor="@color/colorPrimary"
app:progressTipColor="@color/colorAccent"
app:progressTipEnabled="true"
app:trackColor="@color/colorGray" />val progressBar = AnimatedProgressBar(this)
progressBar.setMax(100)
progressBar.setProgress(75)
progressBar.setTrackColor(Color.GRAY)
progressBar.setProgressColor(Color.GREEN)
progressBar.setProgressTipEnabled(true)
progressBar.setProgressTipColor(Color.RED)
progressBar.setAnimDuration(1200)
progressBar.setProgressStyle(AnimatedProgressBar.Style.SNAKE)
progressBar.setLineWidth(dpToPx(5, this).toInt())Use AnimatedProgressBarStyle in new code and in commonMain. Android callers passing the View's AnimatedProgressBar.Style can use the deprecated compatibility overload.
import com.mckrpk.animatedprogressbar.compose.AnimatedProgressBar
import com.mckrpk.animatedprogressbar.compose.AnimatedProgressBarStyle
AnimatedProgressBar(
progress = 75,
max = 100,
style = AnimatedProgressBarStyle.SNAKE,
trackColor = Color.Gray,
progressColor = Color.Green,
progressTipEnabled = true,
progressTipColor = Color.Red,
lineWidth = 5.dp,
animationDurationMillis = 1200,
modifier = Modifier.padding(horizontal = 8.dp)
)Every change of progress, max, style or animationDurationMillis replays the animation, like setProgress() does. The bar fills the available width and is max(32dp, 3 * lineWidth) high unless the modifier sets another size. Default colors, line width and duration are the same as in the View version (see AnimatedProgressBarDefaults). On Android the default progress and tip colors come from the theme's colorPrimary and colorAccent; on other platforms they are fixed.
app: Android sample with the View version and a screen comparing it with the Compose version. On a fresh checkout, set android.useAndroidX=true in the root gradle.properties or pass -Pandroid.useAndroidX=true to Gradle.iosApp: iOS sample using the Compose version (UI in the sample-ios module). Needs XcodeGen:
cd iosApp && xcodegen generate && open iosApp.xcodeprojDEVELOPMENT_TEAM in iosApp/project.yml to run it on a device. SmokeUITests taps the button and saves screenshots of the animation.Copyright 2019 Michał Karpiuk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Please don't hesitate to star the library if you find it useful or interesting. 😊
Animated determinate horizontal progress bar for Android Views and Compose on Android, iOS, and desktop.
Add the View artifact to your app module. It supports API 14 and up and has no Compose dependencies.
dependencies {
implementation 'io.github.mckrpk:AnimatedProgressBar:1.2.0'
}Add the Compose artifact to your Compose-enabled app module. Gradle selects the Android variant automatically. It supports API 21 and up.
dependencies {
implementation 'io.github.mckrpk:AnimatedProgressBar-compose:1.2.0'
}Add the same artifact to commonMain of your Compose Multiplatform module. It supports Android, iOS (iosArm64, iosSimulatorArm64, iosX64), and desktop JVM.
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.mckrpk:AnimatedProgressBar-compose:1.2.0")
}
}
}Add the View to your layout. If the root already declares the app namespace, reuse it. The color resources below are examples from the Android sample. Supply your own resources or omit the color attributes to use the defaults.
<com.mckrpk.animatedprogressbar.AnimatedProgressBar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/animatedProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:animationDurationInMs="1600"
app:animationStyle="snake"
app:lineWidth="6dp"
app:max="1000"
app:progress="750"
app:progressColor="@color/colorPrimary"
app:progressTipColor="@color/colorAccent"
app:progressTipEnabled="true"
app:trackColor="@color/colorGray" />val progressBar = AnimatedProgressBar(this)
progressBar.setMax(100)
progressBar.setProgress(75)
progressBar.setTrackColor(Color.GRAY)
progressBar.setProgressColor(Color.GREEN)
progressBar.setProgressTipEnabled(true)
progressBar.setProgressTipColor(Color.RED)
progressBar.setAnimDuration(1200)
progressBar.setProgressStyle(AnimatedProgressBar.Style.SNAKE)
progressBar.setLineWidth(dpToPx(5, this).toInt())Use AnimatedProgressBarStyle in new code and in commonMain. Android callers passing the View's AnimatedProgressBar.Style can use the deprecated compatibility overload.
import com.mckrpk.animatedprogressbar.compose.AnimatedProgressBar
import com.mckrpk.animatedprogressbar.compose.AnimatedProgressBarStyle
AnimatedProgressBar(
progress = 75,
max = 100,
style = AnimatedProgressBarStyle.SNAKE,
trackColor = Color.Gray,
progressColor = Color.Green,
progressTipEnabled = true,
progressTipColor = Color.Red,
lineWidth = 5.dp,
animationDurationMillis = 1200,
modifier = Modifier.padding(horizontal = 8.dp)
)Every change of progress, max, style or animationDurationMillis replays the animation, like setProgress() does. The bar fills the available width and is max(32dp, 3 * lineWidth) high unless the modifier sets another size. Default colors, line width and duration are the same as in the View version (see AnimatedProgressBarDefaults). On Android the default progress and tip colors come from the theme's colorPrimary and colorAccent; on other platforms they are fixed.
app: Android sample with the View version and a screen comparing it with the Compose version. On a fresh checkout, set android.useAndroidX=true in the root gradle.properties or pass -Pandroid.useAndroidX=true to Gradle.iosApp: iOS sample using the Compose version (UI in the sample-ios module). Needs XcodeGen:
cd iosApp && xcodegen generate && open iosApp.xcodeprojDEVELOPMENT_TEAM in iosApp/project.yml to run it on a device. SmokeUITests taps the button and saves screenshots of the animation.Copyright 2019 Michał Karpiuk
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Please don't hesitate to star the library if you find it useful or interesting. 😊