android adjust view bounds after animation is finished -


i have horizontal linear layout has 3 children; textview sandwiched between 2 buttons.

i have set linearlayout focusable, , buttons not focusable, , added following onfocuschangelistener linearlayout:

        public void onfocuschange(final view v, boolean hasfocus)         {             if(hasfocus)             {                 v.startanimation(_anims.expand());             }             else             {                 v.startanimation(_anims.unexpand());             }         } 

the animations follows:

expand:

<scale xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fillenabled="true" android:fillafter="true" android:fromxscale="1.0" android:toxscale="1.2" android:fromyscale="1.0" android:toyscale="1.1" android:pivotx="50%" android:pivoty="50%" android:duration="200" /> 

and unexpand:

<scale xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:fillenabled="true" android:fromxscale="1.2" android:toxscale="1.0" android:fromyscale="1.1" android:toyscale="1.0" android:pivotx="50%" android:pivoty="50%" android:duration="50" /> 

everything appears work ok, unfortunately when linearlayout expanded, clickable area of buttons appear still appear in 'unexpanded' state - ie @ scale of 0, not matching buttons on screen.

to attempt combat thought of removing fillenabled , fillafter tags, , adding animationwatcher animation - setting scale appropriate value when animation finished. causes slight 'flick' effect view going original size before being expanded again once animation finished.

this happens because viewanimation not change actual position , size of view. have set animation listeners , resize view accordingly.

but there easy way if developing >honeycomb : objectanimator

quote http://developer.android.com/

objectanimator anim = objectanimator.offloat(foo, "scale", 0f, 1f); anim.setduration(1000); anim.start(); 

by using not need use animationlisteners.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -