首页 电脑 电脑学堂 查看内容

位移动画

2015-1-12 11:33 843 0

摘要: 位移动画[java] view plaincopypublic class MainActivity extends Activity im...
关键词: nbsp CD EE FF 00 0000 EEE CDC CDCD FFFF

位移动画[java] view plaincopypublic 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);      }  }  
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系 [邮箱地址] 删除

路过

雷人

握手

鲜花

鸡蛋

最新评论

返回顶部