实现的效果图如下:
使用方法ProgressBar ,如果感觉 这个动画不是自己想要的,需要根据ui的图片来实现只需要将xml中的animated-rotate
修改为animation-list
贴出代码 xml 中
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="/apk/res/android"xmlns:tools="/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"tools:context=".MainActivity"><ProgressBarandroid:id="@+id/loading"android:layout_width="100dp"android:layout_height="100dp"android:layout_gravity="center"android:layout_centerInParent="true"android:indeterminateBehavior="repeat"android:indeterminateDrawable="@drawable/anim" /></RelativeLayout>
drawable 中的代码如下:
<?xml version="1.0" encoding="utf-8"?><animated-rotate xmlns:android="/apk/res/android"android:drawable="@drawable/loading"android:fromDegrees="0.0"android:pivotX="50.0%"android:pivotY="50.0%"android:toDegrees="360.0" />
这样就实现了菊花的动画效果,
当然如果要实现ui设计的动画图的效果,将xml中的animated-rotate修改为animation-list
<?xml version="1.0" encoding="utf-8"?><animation-list xmlns:android="/apk/res/android"><itemandroid:drawable="@mipmap/loading1"android:duration="28" /><itemandroid:drawable="@mipmap/loading2"android:duration="28" /><itemandroid:drawable="@mipmap/loading3"android:duration="28" /><itemandroid:drawable="@mipmap/loading4"android:duration="28" /><itemandroid:drawable="@mipmap/loading5"android:duration="28" /><itemandroid:drawable="@mipmap/loading6"android:duration="28" /><itemandroid:drawable="@mipmap/loading7"android:duration="28" /><itemandroid:drawable="@mipmap/loading8"android:duration="28" /><itemandroid:drawable="@mipmap/loading9"android:duration="28" /><itemandroid:drawable="@mipmap/loading10"android:duration="28" /><itemandroid:drawable="@mipmap/loading11"android:duration="28" /><itemandroid:drawable="@mipmap/loading12"android:duration="28" /></animation-list>