A custom progress indicator view to give your android application a nice feel.
Add it in your root build.gradle
at the end of repositories:
allprojects {
repositories {
//...omitted for brevity
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation "com.github.certified84:CustomProgressIndicator:$latest_release"
}
Sample implementation here
- Add
CustomProgressIndicator
to your xml layout.
<com.certified.customprogressindicatorlibrary.CustomProgressIndicator
android:id="@+id/indicator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:elevation="4dp" />
- Make sure it fills the width and height of the parent view
- The elevation tag ensures it stays above views like buttons and cards
var indicator: CustomProgressIndicator = findViewById(R.id.indicator)
// ViewBinding
var indicator = binding.indicator
indicator.setTextSize(resources.getDimension(R.dimen.30sp))
indicator.setTextColor(ResourcesCompat.getColorStateList(resources, R.color.white, null)!!)
indicator.setText("Loading...")
indicator.setTypeface(R.font.space_grotesk_regular)
indicator.setProgressIndicatorColor("#FFFFFF")
indicator.setTrackColor("#B32821")
indicator.setImageResource(R.drawable.ic_logo)
// Perform operation that needs loading, show the view and start the animation
if(isLoading) {
indicator.apply {
visibility = View.Visible
startAnimation()
}
}
// Always check if the view is visible in onResume and start the animation
override fun onResume() {
super.onResume()
if(indicator.isVisible)
indicator.startAnimation()
//...omitted for brevity
}
indicator.stopAnimation()
// Always stop the animation in onPause()
override fun onPause() {
super.onPause()
indicator.stopAnimation()
//...omitted for brevity
}
- Please create an issue if you find something wrong
- Feel free to contibute. See Contributing Guidelines.
Licensed under the Apache-2.0 License
Copyright 2022 Samson Achiaga
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.