Transform and scale animation on a View

ⅰ亾dé卋堺 提交于 2019-12-11 09:24:55

问题


I have a linear layout with three images in it. On the click of any ImageView I want to animate the whole linear layout. The animation consists of two animations - scale and transform. I don't know how to perform this animation.

This is what I want -

Image 1 - Before Animation

Image 2 - After Animation

I want to not only animate the View but actually shift the view to its new location with animation. After animation I should be able to click the Images at their new locatoin not the old location.

How can I perform this? Please help me out.


回答1:


I used nineoldandroids library to achieve this animation. I used two animation: translation and scaling.

Translation:

ObjectAnimator.ofFloat(frameCategoryScroll, "translationY", 0, -yValue).setDuration(600).start();

yValue is the the value in y axis upto which I want to translate.

Scaling:

ObjectAnimator.ofFloat(frameCategoryScroll, "scaleX", 1.0f, 0.6f).setDuration(600).start();
ObjectAnimator.ofFloat(frameCategoryScroll, "scaleY", 1.0f, 0.6f).setDuration(600).start();


来源:https://stackoverflow.com/questions/22423753/transform-and-scale-animation-on-a-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!