安卓的各种动画(透明度,平移,旋转,缩放)以及侦听
来源:互联网 发布:ladynyc小薇代购知乎 编辑:程序博客网 时间:2024/05/16 23:01
透明度动画:
第一种方式:
AlphaAnimation aa = new AlphaAnimation(0, 1);
aa.setDuration(1000);
imageview.startAnimation(aa);
第二种方式:
imageview.startAnimation(AnimationUtils.loadAnimation(getActivity(), R.anim.aa));
aa.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0"
android:toAlpha="1"
android:duration="1000" >
</alpha>
旋转动画:
第一种方式:
RotateAnimation ra = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
// ra = new RotateAnimation(0, 360, 100, 50);
ra.setDuration(1000);
imageview.startAnimation(aa);
第二种方式:
imageview.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.ra));
ra.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:duration="1000"
android:pivotX="50%"
android:pivotY="50%" >
</rotate>
平移动画:
第一种方式:
TranslateAnimation ta = new TranslateAnimation(0, 200, 0, 200);
ta.setDuration(1000);
imageview.startAnimation(ta);
第二种方式:
imageview.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.ta));
ta.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0"
android:toXDelta="200"
android:fromYDelta="0"
android:toYDelta="200"
android:duration="1000" >
</translate>
缩放动画:
第一种方式:
ScaleAnimation sa = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
// sa = new ScaleAnimation(0, 1, 0, 1,100,50);
sa.setDuration(1000);
imageview.startAnimation(sa);
第二种方式:
imageview.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.sa));
sa.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXScale="0"
android:toXScale="1"
android:fromYScale="0"
android:toYScale="1"
android:duration="1000"
android:pivotX="50%"
android:pivotY="50%" >
</scale>
动画效果混合:
第一种方式:
AnimationSet as= new AnimationSet(true);
as.setDuration(1000);
AlphaAnimation aa = new AlphaAnimation(0, 1);
aa.setDuration(1000);
as.addAnimation(aa);
TranslateAnimation ta = new TranslateAnimation(200, 0, 200, 0);
ta.setDuration(1000);
as.addAnimation(ta);
imageview.startAnimation(as);
第二种方式:
imageview.startAnimation(AnimationUtils.loadAnimation(MainActivity.this, R.anim.anim));
anim.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:shareInterpolator="true" >
<alpha
android:fromAlpha="0"
android:toAlpha="1" />
<translate
android:fromXDelta="200"
android:fromYDelta="200"
android:toXDelta="0"
android:toYDelta="0" />
</set>
动画效果侦听:
Animation a = AnimationUtils.loadAnimation(MainActivity.this, R.anim.anim);
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Toast.makeText(MainActivity.this, "Animation end", Toast.LENGTH_SHORT).show();
}
});
imageview.startAnimation(a);
- 安卓的各种动画(透明度,平移,旋转,缩放)以及侦听
- android动画(平移,旋转,缩放,透明度)
- 安卓动画(旋转,平移,透明,缩放,帧动画)
- 旋转平移,缩放,透明度渐变的补间动画
- 旋转、平移、缩放和透明度渐变的补间动画
- Android动画基础:平移、缩放、旋转、透明度
- Android动画复习(包括缩放动画、平移动画、旋转动画、透明度动画)
- 安卓动画 移位,缩放,旋转,透明度简单实现
- 【Android开发】动画范例2-旋转、平移、缩放和透明度渐变的补间动画
- 【安卓】自定义基于onDraw的任意动画(不仅仅是平移/旋转/缩放/alpha)、!
- Android 通过Animate硬编码实现简单的平移、旋转、缩放及透明度动画过程
- Android 旋转、平移、缩放和透明度渐变的补间动画
- Android 补间动画,具体介绍了透明度、平移,旋转,缩放4种动画效果的实现,简单易懂
- (安卓)属性动画 (平移,旋转,透明)
- Android动画(透明度,平移,旋转,拉伸,动态添加按钮)
- android游戏开发5-10 补间动画 透明度渐变 旋转 缩放 平移
- [CAAnimation核心动画练习一]普通的平移,旋转,缩放
- css3平移、旋转、倾斜、缩放、动画效果的实现
- SSL编程(3).NET实现SSL服务端
- Eclipse中高亮显示相同的变量
- 【leetcode】19. Remove Nth Node From End of List
- 毛玻璃之android.support.v8.renderscript.RSRuntimeException
- 安卓手机开发工具airdroid介绍
- 安卓的各种动画(透明度,平移,旋转,缩放)以及侦听
- IPC网络高清摄像机基础知识6(CCD 与 CMOS传感器)
- node.js学习笔记(8)--multer模块文件上传
- 维护篇(5.2)-11. FortiClient 安装报错 ❀ 飞塔 (Fortinet) 防火墙
- html——<a>标签
- 我的项目框架介绍 -(1)
- 在 idea 中使用 gradle 导入maven仓库
- PostgreSQL 9.2 创建数据库,导入和导出数据库,创建超级用户
- Material Design 一