控件动画效果

来源:互联网 发布:农村淘宝怎么开通 编辑:程序博客网 时间:2024/04/29 06:19
imageView = (ImageView) findViewById(R.id.btn_border);int bmpW = BitmapFactory.decodeResource(getResources(),R.drawable.talk_border).getWidth();// 获取图片宽度DisplayMetrics dm = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(dm);int screenW = dm.widthPixels;// 获取分辨率宽度int offset = screenW / 4 - bmpW;// 计算偏移量Matrix matrix = new Matrix();matrix.postTranslate(offset, 0);imageView.setImageMatrix(matrix);// 设置动画初始位置
AnimationSet AnimationSet = new AnimationSet(true);TranslateAnimation TranslateAnimation;TranslateAnimation = new TranslateAnimation(0, screenW / 4, 0f, 0f);//(动画移动位置{起始位置,结束位置,0f,0f})AnimationSet.addAnimation(TranslateAnimation);AnimationSet.setFillBefore(false);AnimationSet.setFillAfter(true);AnimationSet.setDuration(100);imageView.startAnimation(AnimationSet);


0 0
原创粉丝点击