繁体   English   中英

如何在 Android 中制作进度条的进度动画?

[英]How do I animate the progress of a progress bar in Android?

我当前的进度条代码activity_main.xml是这样的:

<ProgressBar
    android:id="@+id/my_progressBar"
    style="@style/Widget.AppCompat.ProgressBar.Horizontal"
    android:layout_width="282dp"
    android:layout_height="52dp"
    android:layout_marginStart="28dp"
    android:layout_marginTop="428dp"
    android:indeterminate="false"
    android:max="1854"
    android:progress="1572"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

产生这个: 在此处输入图像描述

有人可以指导我如何使进度条从零开始并在应用程序打开后到达当前点吗? https://mechakeys.robolab.io/查看屏幕底部,了解我正在尝试做什么。

这是实现 progressView 的基本示例

<com.skydoves.progressview.ProgressView
  android:id="@+id/progressView1"
  android:layout_width="match_parent"
  android:layout_height="35dp"
  app:progressView_colorBackground="@color/white" // the color of the container.
  app:progressView_colorProgress="@color/skyBlue" // the color of the progress bar.
  app:progressView_progress="40" // progress value.
  app:progressView_min="15" // min progress value.
  app:progressView_max="100" // max progress value.
  app:progressView_progressFromPrevious="true" // animates progress from previous progress.
  app:progressView_autoAnimate="true" // starts filling animation automatically when finishing inflate.
  app:progressView_radius="12dp" // the corner radius of the progressView and progress bar.
  app:progressView_padding="1dp" // the padding of the progress bar.
  app:progressView_labelColorInner="@color/white" // the text color when the label placed on the progress bar.
  app:progressView_labelColorOuter="@color/black" // the text color when the label placed out of the progress bar.
  app:progressView_labelSize="13sp" // the label text size.
  app:progressView_labelSpace="10dp" // the space size of the between label and progress bar. 
  app:progressView_labelText="achieve 65%" // the text of the label.
  app:progressView_labelTypeface="bold" // the typeface of the label.
 />

dependencies {
    implementation "com.github.skydoves:progressview:1.0.9"
}

有关详细信息,请在此处查看

这个progressbar显示ProgressBar的进度

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM