码迷,mamicode.com
首页 > 移动开发 > 详细

Android 给layout设置动画的两种方式

时间:2015-03-29 10:51:23      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

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;
}


}

Android 给layout设置动画的两种方式

标签:

原文地址:http://blog.csdn.net/luo446718254/article/details/44724823

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!