Android移动图片到指定位置

来源:互联网 发布:交换机端口速率 编辑:程序博客网 时间:2024/05/10 08:53
ImageView hero = (ImageView)findById(R.id.hero);int[] location = new int[2];hero.getLocationInWindow(location);//获取Imageview在屏幕中的位置Animation heroTranslate = new TranslateAnimation(location[0]-150f,location[0],0f,0f);//移动动画hero.setAnimation(heroTranslate);heroTranslate.setDuration(1000);hero.setImageDrawable(getResources().getDrawable(R.mipmap.hero_bg));heroTranslate.start();
0 0