Reputation: 1
I want a Circular Indeterminate ProgressBar to be visible for a few milliseconds.
I have created a function to display the progress bar:
fun showProg(){
binding.progBar.visibility = View.VISIBLE
binding.progBar.visibility = View.INVISIBLE
}
Upvotes: 0
Views: 122
Reputation: 1402
I think show/hide ProgressBar with time delay is not a good user experience and probably place of error.
It would be better to change progressBar state by behaviour, not time delay (for example: when data is loading progressBar is visible and invisible when loading completes).
But for your purpose will work fine this:
fun showProg(delayInMillis: Long) {
with(binding.progBar) {
visibility = View.VISIBLE
postDelayed(delayInMillis) {
visibility = View.INVISIBLE
}
}
}
Upvotes: 1