700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > Android ProgressBar 加载中界面实现(loading 动画) 实现菊花的效果

Android ProgressBar 加载中界面实现(loading 动画) 实现菊花的效果

时间:2020-07-17 17:26:30

相关推荐

Android  ProgressBar 加载中界面实现(loading 动画) 实现菊花的效果

实现的效果图如下:

使用方法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>

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。