android - How to programmatically animate shifting fragments? -
i want click button , have view containers change size smoothly/transitionally. can done in android?
if view container mean viewgroup can use valueanimator. it's simple timing engine can use animation.
for example if want animate change of height relativelayout rl finalheight startheight in 400ms can :
valueanimator va = valueanimator.offloat(0f, 1f); va.setduration(400); va.addupdatelistener(new valueanimator.animatorupdatelistener() { public void onanimationupdate(valueanimator animation) { float value = (float) animation.getanimatedvalue(); rl.height = (int) (startheight + (finalheight - startheight) * value); rl.requestlayout(); } });
you can use different interpolator , customize valueanimator nice effect. http://developer.android.com/reference/android/animation/valueanimator.html
Comments
Post a Comment