Android实现ProgressBar旋转菊花加载的动画
在一些常见到的加载中需要显示一个加载动画,如旋转的菊花这样的动画效果,开发中有两种方案,一种是直接让设计师给出一个gif图片,然后写入到布局,另外一种,使用Android动画,把一张静止的图片动起来,本例用后者实现。
写一个xml布局,把ProgressBar放进去:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/loading"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
android:indeterminateBehavior="repeat"
android:indeterminateDrawable=