java - ObjectAnimator vs TranslateAnimation -


i simple project try show/hide layout on top of linearlayout translateanimation. there flicker because when call onanimationend(), animation wasn't finished 0.1sec.

example:

            @override             public void onanimationend(animation animation) {                 retractablelayout.setvisibility(view.gone);             } 

when search on stackoverflow, found there's way it. objectanimator. after using it, animation fine without view.gone

what difference between translateanimation , objectanimator? 1 of them deprecated , same thing or there's time when 1 or other better.

here's github repo 2 versions (https://github.com/charlesvigneault/aaa_test1)

thanks

the difference if use translateanimation, view animating not leave original position on screen, makes moving. view doesnt change coordinates.

check video view animations : https://www.youtube.com/watch?v=_uwxqfbf86u

if use objectanimator view changes actual position.

translateanimation not deprecated, can still find on lollipop, cases can recommend class called viewpropertyanimator , many people still dont seem know about, easiest , straight forward way animate view, , can save lot of code. heres example :

retractablelayout.animate()                 .translationx(tox)                 .translationy(toy)                 .setduration(duration)                 .setinterpolator(interpolator)                 .setstartdelay(startdelay); 

you can set listener etc., sure check available methods.

and check out helpful video :

https://www.youtube.com/watch?v=3ubjhmkesig


Comments

Popular posts from this blog

java - Could not locate OpenAL library -

c++ - Delete matches in OpenCV (Keypoints and descriptors) -

sorting - opencl Bitonic sort with 64 bits keys -