如何在 Android 中创建像图像一样的进度条
How to create Progress Bar like Image in Android
如何在我的 Android 应用中创建以下图像类型的进度环。我想在我的整个应用程序加载到设备之前 10 秒显示它。我也想旋转它。喜欢 window 设备旋转。任何帮助表示赞赏。我是 Andorid 新手。
图片:
- 最近在这里讨论了这个问题。看看吧。
简而言之 - 您可以使用
- 自定义可绘制对象
- 动画列表
这两种方法都可以像您一样创建进度条。
我得到了完美的答案。
使用这个 link 我找到了圆形进度环。
然后我使用这个代码:
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>
最终输出为:
您可以使用此库以更简单的方式完成此操作。此外,还有许多直观的 progressBar 类型可供您使用。
u 可以使用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 文件
使用Lottie 动画。
参见:https://github.com/airbnb/lottie-android
库中的 LottieDrawable 包含方法 progress(),如果加载的图像是进度图像,它会设置正确的框架。
如何在我的 Android 应用中创建以下图像类型的进度环。我想在我的整个应用程序加载到设备之前 10 秒显示它。我也想旋转它。喜欢 window 设备旋转。任何帮助表示赞赏。我是 Andorid 新手。
图片:
简而言之 - 您可以使用
- 自定义可绘制对象
- 动画列表
这两种方法都可以像您一样创建进度条。
我得到了完美的答案。
使用这个 link 我找到了圆形进度环。
然后我使用这个代码:
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>
最终输出为:
您可以使用此库以更简单的方式完成此操作。此外,还有许多直观的 progressBar 类型可供您使用。
u 可以使用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 文件
使用Lottie 动画。 参见:https://github.com/airbnb/lottie-android 库中的 LottieDrawable 包含方法 progress(),如果加载的图像是进度图像,它会设置正确的框架。