2024年Android最新Android旋转动画(1),面试基础知识

最后笔者收集整理了一份Flutter高级入门进阶资料PDF

以下是资料目录和内容部分截图



里面包括详细的知识点讲解分析,带你一个星期入门Flutter。还有130个进阶学习项目实战视频教程,让你秒变大前端。

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。

需要这份系统化学习资料的朋友,可以戳这里获取

一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!



    /**

     * Constructor to use when building a RotateAnimation from code

     * 

     * @param fromDegrees Rotation offset to apply at the start of the animation.

     * @param toDegrees Rotation offset to apply at the end of the animation.

     * @param pivotX The X coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the left edge.

     * @param pivotY The Y coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the top edge.

     */

    public RotateAnimation(float fromDegrees, float toDegrees, float pivotX, float pivotY) {

        mFromDegrees = fromDegrees;

        mToDegrees = toDegrees;



        mPivotXType = ABSOLUTE;

        mPivotYType = ABSOLUTE;

        mPivotXValue = pivotX;

        mPivotYValue = pivotY;

        initializePivotPoint();

    }

  • 头两个参数和上面两个参数的构造方法一样,是开始和结束的角度

  • 后两个参数是设置图片的旋转中心

用法


RotateAnimation ta = new RotateAnimation(0, 360, iv.getWidth() / 2, iv.getHeight() / 2);

// 设置动画播放的时间

ta.setDuration(1000);

// 开始播放动画

iv.startAnimation(ta);

效果

以图片中心为旋转中心,顺时针旋转360度


6个参数的构造方法



/**

* Constructor to use when building a RotateAnimation from code

* 

* @param fromDegrees Rotation offset to apply at the start of the animation.

* @param toDegrees Rotation offset to apply at the end of the animation.

* @param pivotXType Specifies how pivotXValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.

* @param pivotXValue The X coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the left edge. This value can either be an absolute number if pivotXType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.

* @param pivotYType Specifies how pivotYValue should be interpreted. One of Animation.ABSOLUTE, Animation.RELATIVE_TO_SELF, or Animation.RELATIVE_TO_PARENT.

* @param pivotYValue The Y coordinate of the point about which the object is being rotated, specified as an absolute number where 0 is the top edge. This value can either be an absolute number if pivotYType is ABSOLUTE, or a percentage (where 1.0 is 100%) otherwise.

*/

public RotateAnimation(float fromDegrees, float toDegrees, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue) {

   mFromDegrees = fromDegrees;

   mToDegrees = toDegrees;



   mPivotXValue = pivotXValue;

   mPivotXType = pivotXType;

   mPivotYValue = pivotYValue;

   mPivotYType = pivotYType;

   initializePivotPoint();

}

  • 比4个参数的构造方法多了第三个和第五个参数,其他用法一样,第三个和四五个参数分别设置第四个和第六个参数的类型,四个参数的构造没有设置,是默认设置了Animation.ABSOLUTE类型

用法


// 创建旋转的动画对象

RotateAnimation ta = new RotateAnimation(0, 360, RotateAnimation.RELATIVE_TO_SELF, 0.5f, RotateAnimation.RELATIVE_TO_SELF, 0.5f);

// 设置动画播放的时间

ta.setDuration(1000);

// 开始播放动画

iv.startAnimation(ta);

效果

和上面一样,以图片中心为旋转中心,顺时针旋转360度。


设置动画重复播放的次数的方法



/**

 * Sets how many times the animation should be repeated. If the repeat

 * count is 0, the animation is never repeated. If the repeat count is

 * greater than 0 or {@link #INFINITE}, the repeat mode will be taken

 * into account. The repeat count is 0 by default.

 *

 * @param repeatCount the number of times the animation should be repeated

 * @attr ref android.R.styleable#Animation_repeatCount

 */

public void setRepeatCount(int repeatCount) {

    if (repeatCount < 0) {

        repeatCount = INFINITE;

    }

    mRepeatCount = repeatCount;

}

使用


sa.setRepeatCount(2);

一直重复


sa.setRepeatCount(Animation.INFINITE);


设置动画重复播放的模式的方法



/**

 * Defines what this animation should do when it reaches the end. This

 * setting is applied only when the repeat count is either greater than

 * 0 or {@link #INFINITE}. Defaults to {@link #RESTART}. 

 *

 * @param repeatMode {@link #RESTART} or {@link #REVERSE}

 * @attr ref android.R.styleable#Animation_repeatMode

 */

public void setRepeatMode(int repeatMode) {

    mRepeatMode = repeatMode;

}



### 最后

> 文章不易,如果大家喜欢这篇文章,或者对你有帮助希望大家多多点赞转发关注哦。文章会持续更新的。绝对干货!!!

* **Android进阶学习全套手册**
  关于实战,我想每一个做开发的都有话要说,对于小白而言,缺乏实战经验是通病,那么除了在实际工作过程当中,我们如何去更了解实战方面的内容呢?实际上,我们很有必要去看一些实战相关的电子书。目前,我手头上整理到的电子书还算比较全面,HTTP、自定义view、c++、MVP、Android源码设计模式、Android开发艺术探索、Java并发编程的艺术、Android基于Glide的二次封装、Android内存优化——常见内存泄露及优化方案、.Java编程思想 (第4版)等高级技术都囊括其中。

![](https://img-blog.csdnimg.cn/img_convert/b15893146c849675019711d18ef278e2.webp?x-oss-process=image/format,png)

* **Android高级架构师进阶知识体系图**
  关于视频这块,我也是自己搜集了一些,都按照Android学习路线做了一个分类。按照Android学习路线一共有八个模块,其中视频都有对应,就是为了帮助大家系统的学习。接下来看一下导图和对应系统视频吧!!!
  ![](https://img-blog.csdnimg.cn/img_convert/d778ff5ad5ba89900f2ec4ccecfad1e4.webp?x-oss-process=image/format,png)

* **Android对标阿里P7学习视频**

![](https://img-blog.csdnimg.cn/img_convert/0ce2e9cb9f629b5add4dc85a712d8914.webp?x-oss-process=image/format,png)

* **BATJ大厂Android高频面试题**
  这个题库内容是比较多的,除了一些流行的热门技术面试题,如Kotlin,数据库,Java虚拟机面试题,数组,Framework ,混合跨平台开发,等
  ![](https://img-blog.csdnimg.cn/img_convert/61628f0dad4614466d69411c36d70b1c.webp?x-oss-process=image/format,png)



**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化学习资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618156601)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

据库,Java虚拟机面试题,数组,Framework ,混合跨平台开发,等
  [外链图片转存中...(img-RPShUeIH-1715661006801)]



**网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。**

**[需要这份系统化学习资料的朋友,可以戳这里获取](https://bbs.csdn.net/topics/618156601)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值