Tôi có chế độ xem (customView) được thêm vào WindowManager.Chế độ xem hoạt ảnh được thêm trên 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);
Bên trong chế độ xem tùy chỉnh, tôi sẽ gọi hoạt ảnh dịch khi nhấn nút đóng.
//// Đây là handler cho các hình ảnh động ////
final Handler translateHandler = new Handler();
final Runnable mtranslateUp = new Runnable() {
public void run() {
Log.v("TEST","mtranslateUp Runnable");
startAnimation(translateUp);
}
};
//// Đây là người biết lắng nghe cho các nút đóng ////
View.OnClickListener closeButtonListener = new View.OnClickListener() {
public void onClick(View v) {
translateHandler.post(mtranslateUp);
}
};
//// Đây là bản dịch hoạt hình ////
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");
}}
);
Nếu customView được thêm vào hoạt động, các mã này hoạt động tốt!
Khi customView được thêm vào WindowManager, Nhật ký bên trong onAnimationStart không hiển thị nhưng Nhật ký bên trong Runnable có thể được hiển thị.
Ai đó có thể cho biết cách thực hiện hoạt ảnh trên chế độ xem được thêm vào WindowManager?
Bạn có giải pháp nào cho điều này không? Xin vui lòng chia sẻ, tôi cũng phải đối mặt với cùng một vấn đề – om252345