Android Tween无法启动

时间:2016-11-01 19:52:47

标签: android animation android-animation

我想尝试一个非常简单的动画。以下是与此问题相关的代码段:

        ImageView imageView = new ImageView(getBaseContext());
        imageView.setImageResource(R.drawable.default_view_image);

        WindowManager windowManager = getWindowManager();
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_PHONE,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT
        );
        params.gravity = Gravity.TOP | Gravity.LEFT;             
        windowManager.addView(imageView, params);

        TranslateAnimation animation = new TranslateAnimation(0, 0, 0, 200);
        animation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {
                Log.i("start", "called");
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                Log.i("end", "called");
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
                Log.i("repeat", "called");
            }
        });
        imageView.startAnimation(animation);

动画不仅没有启动,Logcat中没有记录任何日志。这意味着,TranslateAnimation 动画根本没有开始。我不明白为什么会这样。请帮忙。

0 个答案:

没有答案