Andorid Popupwindow updates the implementation of the animation, you can achieve a window is pushed up by a window effect

Source: Internet
Author: User

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 ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.