【问题标题】:How to create Progress Bar like Image in Android如何在 Android 中创建类似图像的进度条
【发布时间】:2016-01-27 04:42:48
【问题描述】:

如何在我的 Android 应用中创建以下图像类型的进度环。我想在我的整个应用程序加载到设备上之前 10 秒显示它。我也想旋转它。像窗口设备旋转。任何帮助表示赞赏。我是 Andorid 的新手。

图片:

【问题讨论】:

  • 你可以使用图书馆github.com/castorflex/SmoothProgressBar
  • 我想要像 windows 设备一样的铃声而不是 ProgressBar..
  • CircularProgressBar 厚度在这个库中更多..
  • 检查库,你可以使用这个 fnc - strokeWidth(8f) OR In xml app:cpb_stroke_width="4dp"
  • 但我想要的是圆点制作的戒指。希望你能理解。

标签: android android-layout android-widget progress-bar


【解决方案1】:

我得到了完美的答案。

使用此链接我找到了圆形进度环。

progress_bar.gif

然后我使用这个代码:

animation.xml

<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/progress_bar"
    android:pivotX="50%"
    android:pivotY="50%" />

在我的主 xml 文件中。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"          android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">


    <ProgressBar
        android:id="@+id/progressbar1"
        android:layout_marginTop="80dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:indeterminateDrawable="@anim/animation"/>


</RelativeLayout>

最后的输出是:

【讨论】:

  • 但是有了这个答案,你就不会像在这个 GIF 中那样得到这种慢-快-慢-... 旋转效果。我建议你只使用这个 GIF 并在你想要的时间显示它(为此我相信你已经编写了代码)
  • @AnkitBansal 如果您使用 AccelerateDecelerateInterpolator,它将以慢-快-慢模式进行动画处理。
  • @XaverKapeller 是的,差点忘了
【解决方案2】:

你可以使用gifView库:https://github.com/koral--/android-gif-drawable

使用这是你的 .xml:-

<pl.droidsonroids.gif.GifImageView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/src_anim"
    />

src_anim 是你的加载器 gif 文件

【讨论】:

  • 我尝试了你的答案,但在输出中给了我左右箭头。
  • 请移除 android:background 属性
  • 也使用 1.1.11 版本,因为 1.1.12 有一些奇怪的崩溃问题
【解决方案3】:

Modifying the resource image of Progress Bar - 最近在这里讨论了这个问题。看看吧。

简而言之 - 你可以使用

  • 自定义可绘制对象
  • 动画列表

这两种方法都允许创建像你这样的进度条。

【讨论】:

  • 效果很好 +1,因为我更新了我的问题。
  • Rect 在其他活动中工作正常,但是当我在 Splash Activity 中使用时,这给了我错误。
【解决方案4】:

您可以使用此库以更简单的方式进行操作。此外,还有很多直观的 progressBar 类型可供您使用。

https://github.com/81813780/AVLoadingIndicatorView

【讨论】:

    【解决方案5】:

    使用 Lottie 动画。 见:https://github.com/airbnb/lottie-android 库中的 LottieDrawable 包含方法 progress(),如果加载的图像是进度图像,则设置右帧。

    【讨论】:

      猜你喜欢
      • 2012-09-09
      • 2017-06-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-23
      • 1970-01-01
      • 2021-10-15
      • 2023-03-17
      • 1970-01-01
      相关资源
      最近更新 更多