I have ImageViewwhich I add through WindowManager.addView(ImageView, WindowManager.LayoutParams). I want to animate ImageViewwhen it appears on the screen, but it does not seem animated when I call ImageView.startAnimation(Animation)after the method addView(). Here is my code below ...
image = new ImageView(context);
image.setImageResource(R.drawable.image);
image.setAlpha(180);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, 0, PixelFormat.TRANSLUCENT);
windowManager.addView(image, params);
image.startAnimation(AnimationUtils.loadAnimation(getContext(), R.anim.grow));
This is the grow.xml file
<?xml version="1.0" encoding="UTF-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="0"
android:toXScale="1"
android:fromYScale="0"
android:toYScale="1"
android:pivotX="50%"
android:pivotY="50%"
android:duration="350"/>
<alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="350" />
</set>
The image just appears in the window and doesn’t come to life, does anyone know how I can make the image come to life?
Brian source
share