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

位移动画

时间:2015-01-12 06:50:32      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

位移动画

public class MainActivity extends Activity implements OnClickListener {

	private TextView tv_text;
	private TranslateAnimation animation;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		tv_text = (TextView) findViewById(R.id.tv_text);
		tv_text.onWindowFocusChanged(true);
		//int width = tv_text.getWidth();
		//int measuredWidth = tv_text.getMeasuredWidth();
		int www = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED); 
		int hhh = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED); 
		this.tv_text.measure(www, hhh); 
		// 获取控件的宽度
		int realitemWidth=this.tv_text.getMeasuredWidth(); 
		int realitemHeight=this.tv_text.getMeasuredHeight(); 
		
		animation = new TranslateAnimation(0, realitemWidth,0, 0); 
		
		
		
		animation.setDuration(2000);//设置动画持续时间 
		animation.setFillAfter(true);
		//animation.setRepeatCount(1);//设置重复次数 
		
		tv_text.setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		tv_text.startAnimation(animation);
		Toast.makeText(this, "jife", 0).show();
		this.overridePendingTransition(R.anim.in_from_right, R.anim.out_to_left);
	}
}


位移动画

标签:

原文地址:http://blog.csdn.net/luguoqiang_12/article/details/42630347

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