Android移動圖片到指定位置

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();
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章