29.android写个简单的圆形图片一直旋转的效果

//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>

 

//-------------------------------------------------------------------------------完----------------------------------------------------------------------------

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值