Recently due to the project needs, has been looking for a pop-up window, in another pop-up window pop-up, pushed up the effect, incredibly find, after unremitting efforts, finally realized the Popupwindow in the update when the animation.
First on the code:
1 ImportAndroid.animation.ObjectAnimator;2 ImportAndroid.annotation.SuppressLint;3 ImportAndroid.content.Context;4 Importandroid.graphics.drawable.BitmapDrawable;5 ImportAndroid.util.AttributeSet;6 ImportAndroid.view.LayoutInflater;7 ImportAndroid.view.View;8 ImportAndroid.widget.PopupWindow;9 ImportAndroid.widget.TextView;Ten One Public classNotepopwindowextendsPopupwindow { A PrivateTextView Mnodetextview; - PrivateContext Mcontext; - PrivateViewwrapper Mwrapper; the - PublicNotepopwindow (Context context,intWidthintheight) { - Super(Layoutinflater.from (context). Inflate (R.layout.fullscreen_view_note_popwindow,NULL), width, height); -Mcontext =context; +Setbackgrounddrawable (Newbitmapdrawable ()); - Setanimationstyle (r.style.anim_note_bottombar); + initviews (); A } at - PublicNotepopwindow (Context context) { - Super(context); - - } - in PublicNotepopwindow (Context context, AttributeSet AttributeSet) { - Super(context, attributeset); to } + - Private voidinitviews () { theMnodetextview =(TextView) Getcontentview (). Findviewbyid (R.id.note_view); *Mwrapper =NewViewwrapper (Getcontentview ()); $ }Panax Notoginseng -@SuppressLint ("Newapi") the Public voidstartupanimation () { +Objectanimator translationright = Objectanimator.ofint (Mwrapper, "Y", (int) mcontext.getresources () A . Getdimension (R.dimen.bottom_menu_window_height)); theTranslationright.setduration (540); + Translationright.start (); - } $ $@SuppressLint ("Newapi") - Public voidstartdownanimation () { -Objectanimator translationright = Objectanimator.ofint (Mwrapper, "Y", 0); theTranslationright.setduration (360); - Translationright.start ();Wuyi } the - Private classViewwrapper { Wu PrivateView Mtarget; - Private BooleanIsUp =true; About $ PublicViewwrapper (View target) { - Setmtarget (target); - } - A@SuppressWarnings ("Unused") + Public intGetY () { the if(isUp) { -IsUp =false; $ return0; the the}Else { theIsUp =true; the return(int) mcontext.getresources (). Getdimension (r.dimen.bottom_menu_window_height); - } in the } the About@SuppressWarnings ("Unused") the Public voidSety (intheight) { theUpdate (0, height,-1, 1); the } + -@SuppressWarnings ("Unused") the PublicView Getmtarget () {Bayi returnMtarget; the } the - Public voidSetmtarget (View mtarget) { - This. Mtarget =Mtarget; the } the } the}
The implementation of the principle is to rely on property animation, but the property animation can only be used for the set and get method properties, so the key is to write a wrapper class, provide the property's set and get method, in the Set method call Popwindow Update method, can be implemented in the update animation.
Speak is not very clear, code such as above, if really do not understand can mail, QQ contact ...