使用Kotlin的Android ProgressBar

本文介绍了如何在Android应用中使用Kotlin实现ProgressBar,包括确定和不确定进度条类型,重要的ProgressBar属性,XML布局以及Android项目的具体结构。通过示例代码展示了如何在Kotlin中操作ProgressBar,包括设置进度和处理线程更新。
摘要由CSDN通过智能技术生成

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.

有两种类型的进度栏。

  1. Determinate ProgressBar – This is used when you can track and show the progress completed.

    确定的ProgressBar –当您可以跟踪和显示完成的进度时使用。
  2. 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 ProgressBar

    android:indeterminate –用于指定指示ProgressBar类型的布尔值
  • android:max – The upper limit of the progress

    android:max –进度上限
  • android:min – The lower limit of the progress

    android:min –进度的下限
  • android:progress – The steps by which the progress would be incremented.

    android:progress –逐步增加android:progress的步骤。
  • android:minWidth and minHeight – Used to define the dimensions of the ProgressBar

    android:minWidthminHeight –用于定义ProgressBar的尺寸
  • android:progressBarTint – The tint color of the progress completed of the ProgressBar

    android:progressBarTint – ProgressBar完成android:progressBarTint的色调颜色
  • android:progressBarBackgroundTint – The tint color of the progress completed of the ProgressBar

    android:progressBarBackgroundTint -ProgressBar完成android:progressBarBackgroundTint的色调颜色
  • sty
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值