//1.—————————————————-第一步 圆形图片依赖加xml布局——————————————————
//圆形图片依赖
implementation 'de.hdodenhof:circleimageview:2.1.0'
//xml布局
<de.hdodenhof.circleimageview.CircleImageView
android:src=”@mipmap/ic_launcher”
android:layout_gravity=”center”
android:id=”@+id/imageID”
android:layout_width=”100dp”
android:layout_height=”100dp” />
//2.——————————————————第二步 res下创建文件夹anim,里面再创建anim的xml文件———————
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="5000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="-1"
android:repeatMode="restart"
android:toDegrees="360" />
</set>
duration:时间
fromDegrees="0": 从几度开始转
toDegrees="360" : 旋转多少度
pivotX="50% 旋转中心距离view的左顶点为50%距离,
pivotY="50% 距离view的上边缘为50%距离
repeatCount="-1":重复次数,-1为一直重复
repeatMode="restart":重复模式,restart从头开始重复
android:repeatMode=”reverse”,从结尾开始重复
android:startOffset="-1" 起始偏移量
//3.————————————————————第三步 —————————————————————-
//动画
animation = AnimationUtils.loadAnimation(this, R.anim.anim);
LinearInterpolator lin = new LinearInterpolator();//设置动画匀速运动
animation.setInterpolator(lin);
imageID.startAnimation(animation);
//关闭动画:
imageID.clearAnimation();
注意如果设置animation.cancel()是没有效果的
//我的旋转缩放动画:
// android:repeatCount=”infinite”代表无限执行
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="500">
<rotate
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360" />
<scale
android:repeatCount="infinite"
android:repeatMode="reverse"
android:fromXScale="0.5"
android:fromYScale="0.5"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1.5"
android:toYScale="1.5"
/>
</set>
//我的底部栏切换图标动画:
<set xmlns:android="http://schemas.android.com/apk/res/android" android:duration="500">
<alpha
android:fromAlpha="0.1"
android:toAlpha="5.0"
/>
<scale
android:fromXScale="0.5"
android:fromYScale="0.5"
android:pivotX="50%"
android:pivotY="50%"
android:toXScale="1"
android:toYScale="1"
/>
</set>
//——————————————————————————-完—————————————————————————-
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/118365.html