Windowmanager with Animation

Viewed 8107

First of all thanks everyone who tries to reply this topic.

I have an activity and I wanted to show a sort of menu at the top of the screen and I used windowmanager to handle this. it was about UI issues I encountered why I choise windowmanager to do such a menu. But for now I want this menu to animate but it seems animation takes no effect. Here is my code.

If anyone has any idea how to animate windowmanager I ll be appreciate.

Animation animShowTopLine;

animShowTopLine = AnimationUtils.loadAnimation(this, R.anim.translate);
        animShowTopLine.reset();
LinearLayout top_line;
WindowManager wm;
WindowManager.LayoutParams wmParams;

LayoutInflater inflate = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);

    top_line =    (LinearLayout) inflate.inflate(R.layout.line, null);

    wm =(WindowManager) getApplicationContext().getSystemService("window");

    wmParams =new WindowManager.LayoutParams();

    wmParams.type=2002;
    wmParams.format = 1;
    wmParams.flags=40;
    wmParams.width=WindowManager.LayoutParams.FILL_PARENT;
    wmParams.height=WindowManager.LayoutParams.WRAP_CONTENT;

    wmParams.gravity  = Gravity.TOP;

    wm.addView(top_line, wmParams);


    top_line.startAnimation(animShowTopLine);

Thanks in advance. Regards.

3 Answers
mParams.windowAnimations = android.R.style.Animation_Toast;

Where android.R.style.Animation_Toast is a style resource defining the animations to use for this window. This must be a system resource, it can not be an application resource because the window manager does not have access to applications.

Others valid styles are:

mParams.windowAnimations = android.R.style.Animation_Translucent;
mParams.windowAnimations = android.R.style.Animation_Dialog;
Related