Android 给layout设置动画的两种方式
来源:互联网 发布:网络遭到劫持 编辑:程序博客网 时间:2024/05/22 14:41
public class MainActivity extends Activity {
LinearLayout layout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
layout = (LinearLayout) findViewById(R.id.layout);
layout.setLayoutAnimation(getAnimationController());//这是第一种方式
// layout.startAnimation(getAnimation());//这是第2种方式
}
protected LayoutAnimationController getAnimationController() {
LayoutAnimationController controller;
// AnimationSet set = new AnimationSet(true);
Animation anim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);// 从0.5倍放大到1倍
anim.setDuration(1500);
controller = new LayoutAnimationController(anim, 0.1f);
controller.setOrder(LayoutAnimationController.ORDER_NORMAL);
return controller;
}
protected Animation getAnimation() {
Animation anim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);// 从0.5倍放大到1倍
anim.setDuration(1500);
return anim;
}
}
LinearLayout layout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
layout = (LinearLayout) findViewById(R.id.layout);
layout.setLayoutAnimation(getAnimationController());//这是第一种方式
// layout.startAnimation(getAnimation());//这是第2种方式
}
protected LayoutAnimationController getAnimationController() {
LayoutAnimationController controller;
// AnimationSet set = new AnimationSet(true);
Animation anim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);// 从0.5倍放大到1倍
anim.setDuration(1500);
controller = new LayoutAnimationController(anim, 0.1f);
controller.setOrder(LayoutAnimationController.ORDER_NORMAL);
return controller;
}
protected Animation getAnimation() {
Animation anim = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);// 从0.5倍放大到1倍
anim.setDuration(1500);
return anim;
}
}
0 0
- Android 给layout设置动画的两种方式
- Android设置界面切换动画的两种方式
- Qt两种设置Layout的方式有什么区别
- Android动画的两种使用方式。
- android转场动画的两种方式
- Android_设置动画效果的两种方式
- android动画(3)layout动画,layoutChanged动画及算定义它,ListViewActivity的Layout动画(代码和xm配置两种实现l)
- Android全屏设置的两种方式
- Android全屏设置的两种方式
- Android 设置全屏的两种方式
- Android全屏设置的两种方式
- Android全屏设置的两种方式
- 设置android全屏的两种方式
- Android全屏设置的两种方式
- Android全屏设置的两种方式
- Android全屏设置的两种方式
- 创建android逐帧动画的两种方式
- android中动画实现的两种方式
- Android开发_发短信
- 【SICP练习】138 练习3.69
- JAVA内部类
- 《Apache MINA 2.0 用户指南》第七章:事件处理器
- PHP字符串处理函数示例学习笔记
- Android 给layout设置动画的两种方式
- 《Apache MINA 2.0 用户指南》第八章:字节缓存
- 《第四周RFID作业》物联112118 林家辉
- 线性表-链式实现-循环链表
- Android中获取本机ip地址和MAC地址
- lightoj 1164 - Horrible Queries 线段树入门
- [Java]String,StringBuffer与StringBuilder的区别??
- 《Apache MINA 2.0 用户指南》第九章:编解码器过滤器
- [NFC]Tag设备响应流程