我有一個視圖(customView)添加到WindowManager中。添加在WindowManager上的動畫視圖
WindowManager mWm = (WindowManager)activity.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
WindowManager.LayoutParams(WindowManager.LayoutParams.FILL_PARENT, 0, PixelFormat.TRANSPARENT);
mWl.dimAmount = 0.0f;
mWm.addView(customView, mWl);
在自定義視圖中,當按下關閉按鈕時,我將調用翻譯動畫。
////這是動畫的處理程序////
final Handler translateHandler = new Handler();
final Runnable mtranslateUp = new Runnable() {
public void run() {
Log.v("TEST","mtranslateUp Runnable");
startAnimation(translateUp);
}
};
////這是關閉按鈕聽者////
View.OnClickListener closeButtonListener = new View.OnClickListener() {
public void onClick(View v) {
translateHandler.post(mtranslateUp);
}
};
////這是翻譯動畫////
translateUp = new TranslateAnimation(0,0,0,-200);
translateUp.setFillAfter(true);
translateUp.setDuration(1000);
translateUp.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationEnd(Animation animation) {
Log.v("TEST","translateUp onAnimationEnd");
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationStart(Animation animation) {
Log.v("TEST","translateUp onAnimationStart");
}}
);
如果customView被添加到一個活動,這些代碼工作正常!
將customView添加到WindowManager時,onAnimationStart中的Log沒有顯示,但可以顯示Runnable內的Log。
任何人都可以告訴如何對添加到WindowManager的視圖執行動畫嗎?
你有這方面的解決方案嗎?請分享,我也面臨同樣的問題 – om252345 2012-05-09 19:55:47