2024年安卓最新Android旋转动画,2024年最新java jvm面试

最后

想要了解更多关于大厂面试的同学可以点赞支持一下,除此之外,我也分享一些优质资源,包括:Android学习PDF+架构视频+源码笔记高级架构技术进阶脑图、Android开发面试专题资料,高级进阶架构资料 这几块的内容。非常适合近期有面试和想在技术道路上继续精进的朋友。

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

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

一个人可以走的很快,但一群人才能走的更远!不论你是正从事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;

}



### 最后

只要是程序员,不管是Java还是Android,如果不去阅读源码,只看API文档,那就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。

真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。

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

**腾讯、字节跳动、阿里、百度等BAT大厂 2019-2021面试真题解析**

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

>资料太多,全部展示会影响篇幅,暂时就先列举这些部分截图
>



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

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

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

...(img-0eDSzoj5-1715810459790)]

>资料太多,全部展示会影响篇幅,暂时就先列举这些部分截图
>



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

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值