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();
Android移动图片到指定位置
最新推荐文章于 2021-05-25 16:17:05 发布