In this tutorial, we’ll discuss and implement ProgressBar in our Android Application using Kotlin.
在本教程中,我们将使用Kotlin在Android应用程序中讨论和实现ProgressBar。
什么是ProgressBar? (What is a ProgressBar?)
ProgressBar UI element is used to display the Progress on the app screen. We can use a ProgressBar to show the download/upload progress on the app screen.
ProgressBar UI元素用于在应用程序屏幕上显示进度。 我们可以使用ProgressBar在应用程序屏幕上显示下载/上传进度。
进度条类型 (Progress Bar Types)
There are two types of Progress Bar.
有两种类型的进度栏。
- Determinate ProgressBar – This is used when you can track and show the progress completed. 确定的ProgressBar –当您可以跟踪和显示完成的进度时使用。
- Indeterminate ProgressBar – This one goes infinitely until stopped. 不确定的ProgressBar –此无限进行直到停止。
A ProgressDialog would hold a ProgressBar inside an Alert Dialog. ProgressDialog is now deprecated since it isn’t a good idea to show long progress in a dialog while blocking the screen.
ProgressDialog将在Alert对话框中保存一个ProgressBar。 现在不推荐使用ProgressDialog,因为在阻塞屏幕时在对话框中显示长时间的进度并不是一个好主意。
ProgressBar属性 (ProgressBar Attributes)
Some of the important attributes of ProgressBar are:
ProgressBar的一些重要属性是:
android:indeterminate
– used to specify the boolean value indicating the type of the ProgressBarandroid:indeterminate
–用于指定指示ProgressBar类型的布尔值android:max
– The upper limit of the progressandroid:max
–进度上限android:min
– The lower limit of the progressandroid:min
–进度的下限android:progress
– The steps by which the progress would be incremented.android:progress
–逐步增加android:progress
的步骤。android:minWidth
andminHeight
– Used to define the dimensions of the ProgressBarandroid:minWidth
和minHeight
–用于定义ProgressBar的尺寸android:progressBarTint
– The tint color of the progress completed of the ProgressBarandroid:progressBarTint
– ProgressBar完成android:progressBarTint
的色调颜色android:progressBarBackgroundTint
– The tint color of the progress completed of the ProgressBarandroid:progressBarBackgroundTint
-ProgressBar完成android:progressBarBackgroundTint
的色调颜色sty