Android Animation --ScaleAnimation
Android -- animation
2023-09-11 14:14:55 时间
ScaleAnimation 缩放动画效果 是安卓中的动画效果之一
相关构造初始化方法 ScaleAnimation scale =new
ScaleAnimation(Context context, AttributeSet attrs) 从XML文件加载动画,基本用不到
ScaleAnimation(float fromX, float toX, float fromY, float toY)
ScaleAnimation(float fromX, float toX, float fromY, float toY, float pivotX, float pivotY)
ScaleAnimation(float fromX, float toX, float fromY, float toY, int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)
ScaleAnimation(float fromX, float toX, float fromY, float toY,int pivotXType, float pivotXValue, int pivotYType, float pivotYValue)</span>
float fromX 动画起始时 X坐标上的伸缩尺寸
float toX 动画结束时 X坐标上的伸缩尺寸
float fromY 动画起始时Y坐标上的伸缩尺寸
float toY 动画结束时Y坐标上的伸缩尺寸
int pivotXType 动画在X轴相对于物件位置类型
float pivotXValue 动画相对于物件的X坐标的开始位置
int pivotYType 动画在Y轴相对于物件位置类型
float pivotYValue 动画相对于物件的Y坐标的开始位置
相关的设置
ScaleAnimation scaleAnimation = new ScaleAnimation(0.0f, 1.0f, 1.0f, 1.0f,
Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 1.0f);
//逐渐加速进入的动画 先慢后快
// scaleAnimation.setInterpolator(AnimationUtils.loadInterpolator(this,
// android.R.anim.accelerate_interpolator));
// 加速进入.与第一个的区别为当repeatMode为reverse时,仍为加速返回原点
// scaleAnimation.setInterpolator(AnimationUtils.loadInterpolator(this,
// android.R.anim.accelerate_decelerate_interpolator));
//先向后退一点再加速前进
// scaleAnimation.setInterpolator(AnimationUtils.loadInterpolator(this,
// android.R.anim.anticipate_interpolator));
// //减速前进 冲过终点后再后退
// scaleAnimation.setInterpolator(AnimationUtils.loadInterpolator(this,
// android.R.anim.overshoot_interpolator));
先往后退一点再加速前进 再减速超过一点再后退
// scaleAnimation.setInterpolator(AnimationUtils.loadInterpolator(this,
// android.R.anim.anticipate_overshoot_interpolator));
//停止下来回振几次
scaleAnimation.setInterpolator(AnimationUtils.loadInterpolator(this,
android.R.anim.bounce_interpolator));
//逐渐减速进入的动画 先快后慢
// scaleAnimation.setInterpolator(AnimationUtils.loadInterpolator(this,
// android.R.anim.decelerate_interpolator));
//设置动画启动的延时时间
scaleAnimation.setStartOffset(300);
//设置动画执行的时间
scaleAnimation.setDuration(2000);
//设置重复的次数
scaleAnimation.setRepeatCount(Integer.MAX_VALUE);
// //设置执行的模式 RESTART为结束后重新开始,
// scaleAnimation.setRepeatMode(Animation.RESTART);
// //设置执行的模式为按原来的轨迹逆向返回
scaleAnimation.setRepeatMode(Animation.REVERSE);
// scaleAnimation.setRepeatMode(Animation.START_ON_FIRST_FRAME);
// scaleAnimation.setRepeatMode(Animation.ZORDER_BOTTOM);
// scaleAnimation.setRepeatMode(Animation.ZORDER_NORMAL);
// scaleAnimation.setRepeatMode(Animation.ZORDER_TOP);
//绝对位置
// scaleAnimation.setRepeatMode(Animation.ABSOLUTE);
//无限循环
// scaleAnimation.setRepeatMode(Animation.INFINITE);
//相对于父控件
// scaleAnimation.setRepeatMode(Animation.RELATIVE_TO_PARENT);
//相对于本身
// scaleAnimation.setRepeatMode(Animation.RELATIVE_TO_SELF);
AnimationSet animationSet = new AnimationSet(true);
animationSet.addAnimation(alphaAnimation1);
animationSet.addAnimation(scaleAnimation);
mTvTitleBackground.startAnimation(scaleAnimation);
</pre><pre name="code" class="html">
XML中的定义方式
<pre name="code" class="html"><?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="1.0"
android:toXScale="0.0"
android:fromYScale="1.0"
android:toYScale="0.0"
android:pivotX="50%"
android:pivotY="50%"
android:fillAfter="true"
android:duration="400"
>
</scale>
相关文章
- android--listview设置高度
- 《android开发艺术探索》读书笔记(七)--动画
- 《android开发艺术探索》读书笔记(四)--View工作原理
- 《Android源码设计模式》--享元模式
- 《Android源码设计模式》--单例模式
- 《Android进阶之光》--Dagger2
- 《android开发艺术探索》读书笔记(十五)--Android性能优化
- 《android开发艺术探索》读书笔记(十一)--Android的线程和线程池
- Android studio百度地图demo出现230错误,key校验失败
- Android进阶宝典 -- JetPack Navigation的高级用法(解决路由跳转新建Fragment页面问题)
- Android RatingBar 实现评星功能
- 【Android笔记88】Android之可折叠列表组件ExpandableListView的使用
- 【Android笔记46】Android中如何自定义弹出框样式
- 【Android笔记19】Android中的事件处理(监听和回调事件)
- android 11.0 12.0app应用安装白名单
- Android 12.0 屏蔽FallbackHome机制去掉android正在启动直接进入默认Launcher功能实现
- Android studio 修改项目名称的方法
- 音视频开发-关于 Android 渲染你应该了解的知识点
- 【Kotlin 协程】Flow 异步流 ② ( 使用 Flow 异步流持续获取不同返回值 | Flow 异步流获取返回值方式与其它方式对比 | 在 Android 中使用 Flow 异步流下载文件 )
- 【Android Gradle 插件】DexOptions 配置 ⑤ ( additionalParameters 属性配置 | --minimal-main-dex 参数最小化主 dex 字节码 )
- 【Android 逆向】Android 权限 ( 查看内存信息 | 查看 CPU 信息 | 查看电池信息 | 查看账户信息 | 查看 Activity 信息 | 查看 Package 信息 )
- 【Android 应用开发】Android 开发环境下载地址 -- 百度网盘 adt-bundle android-studio sdk adt 下载
- Android开发之使用Handler封装下载图片工具类(源码分享)
- Android相关属性的介绍:android:exported = true
- 解决Android中No resource found that matches android:TextAppearance.Material.Widget.Button.Inverse问题
- Android 开发 --Unable to resolve target 'android-19'
- 【Android入门】4、数据持久化:文件、SharedPreferences 和 Sqlite
- Kotlin的报错提示:Invoke-customs are only supported starting with Android O (--min-api 26)