android动画(Animation)
来源:互联网 发布:suse11 linux iso下载 编辑:程序博客网 时间:2024/06/05 05:48
AlphaAnimation 透明度
AlphaAnimationalphaAnimation = new AlphaAnimation(0, 1);
alphaAnimation.setDuration(1000);
alphaButton.startAnimation(alphaAnimation);
<?xmlversion="1.0"encoding="utf-8"?>
<alphaxmlns:android="http://schemas.android.com/apk/res/android"
android:fromAlpha="0"
android:toAlpha="1"
android:duration="1000">
</alpha>
RotateAnimation 角度
//RotateAnimation rotateAnimation = new RotateAnimation(0, 360, 50,
// 50);//50,50是相对控件自身的XY偏移量
RotateAnimationrotateAnimation = new RotateAnimation(0, 360,
Animation.RELATIVE_TO_SELF, 0.5f,//旋转点X坐标相对于自身比例一半的位置
Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation.setDuration(1000);
rotateButton.startAnimation(rotateAnimation);
// 调用Xml资源
rotateButton.startAnimation(AnimationUtils.loadAnimation(
MainActivity.this, R.anim.ro));
<?xmlversion="1.0"encoding="utf-8"?>
<rotatexmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:duration="1000"
android:pivotX="50%"
android:pivotY="50%">
</rotate>
ScaleAnimation 缩放
ScaleAnimationscaleAnimation = new ScaleAnimation(1, 1.5f, 1, 2,//x方向由1放大到1.5,y方向由1放大到2
Animation.RELATIVE_TO_SELF, 0.5f,//放大中心点X坐标在一半处
Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(1000);
scaleButton.startAnimation(scaleAnimation);
scaleButton.startAnimation(AnimationUtils.loadAnimation(
MainActivity.this, R.anim.sc));
<?xmlversion="1.0"encoding="utf-8"?>
<scalexmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXScale="1"
android:fromYScale="1"
android:pivotX="50%" xml文件中相对比例用百分比
android:pivotY="50%"
android:toXScale="1.5"
android:toYScale="2">
</scale>
TranslateAnimation 平移
TranslateAnimationtranslateAnimation = new TranslateAnimation(30,
200, 50, 100);// 移动x从30到200,移动y方向从50到100,都是相对像素
translateAnimation.setDuration(1000);
transButton.startAnimation(translateAnimation);
transButton.startAnimation(AnimationUtils.loadAnimation(
MainActivity.this, R.anim.tr));
<?xmlversion="1.0"encoding="utf-8"?>
<translatexmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:fromXDelta="30"
android:fromYDelta="50"
android:toXDelta="200"
android:toYDelta="100">
</translate>
多个Animation组合
AnimationSet animationSet=new AnimationSet(true);
animationSet.addAnimation(rotateAnimation);
rotateButton.startAnimation(animationSet);
动画监听
rotateAnimation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) {
}
@Override
public void onAnimationEnd(Animation arg0) {
}
});
- Android动画-Android Animation
- 【Android】【动画】Android 动画 (Animation)
- Android 动画效果 --Animation
- Android 动画效果 --Animation
- Android 动画效果 --Animation
- Android Animation动画效果
- android Animation 动画效果
- Android的animation(动画)
- Android animation动画
- Android动画--Frame Animation
- Android Property Animation动画
- Android Animation动画
- Android动画(Animation)
- android Animation 动画效果
- Android 动画效果animation
- Android Animation动画体系结构
- Android animation 定义动画
- android animation动画
- HDU 4287 Intelligent IME(哈希)
- KVC与KVO理解
- CNF范式生成器 CNFgen 安装教程
- Eclipse 字符编码设置
- maven 安装使用示例
- android动画(Animation)
- 【Python基础】生成器——generator
- I学霸官方免费教程六:Java基础之流程控制
- 【Android开源项目分析】TAB导航栏PagerSlidingTabStrip的使用和源码分析
- 第一课 MongoDB 概述与安装
- Codeforces Round #295 (Div. 1) B. Cubes(最大最小堆+拓扑模拟)
- jQuery效果之淡入淡出
- SOAPUI 使用groovy发送http请求 自动化测试
- 将指定字符串分割成字符数组