答案 0 :(得分:9)
我得到了完美的答案。
使用此链接我找到了圆形进度环。
然后我使用此代码:
<强> 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>
最后输出是:
答案 1 :(得分:4)
Modifying the resource image of Progress Bar - 最近在这里讨论了这个问题。看看吧。
简而言之 - 您可以使用
这两种方法都可以像你那样创建进度条。
答案 2 :(得分:4)
您可以使用此库以更简单的方式执行此操作。此外,还有很多直观的progressBar类型。
答案 3 :(得分:4)
你可以使用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文件
答案 4 :(得分:1)
使用 Lottie 动画。 参见:https://github.com/airbnb/lottie-android 库中的LottieDrawable包含方法 progress(),如果加载的图像是进度图像,该方法将设置正确的帧。