对 ViewGroup 进行动画处理而不对子视图进行动画处理
最近,我在尝试让自定义 ViewGroup 独立于其子视图进行动画制作(缩放/翻译动画)时遇到了很多麻烦。值得注意的是,我的自定义 ViewGroup 是可见的,而不仅仅是一个容器,因此需要为其设置动画,而不仅仅是它的子项。
我希望我的 ViewGroup 有 2 种状态,未展开和展开,前者能够显示 1 个视图,后者能够显示该视图以及另外 4 个视图(总共 5 个)。
我的 ViewGroup 用于进入/退出展开状态的动画已完成,我对此非常满意。尽管将视图添加到 ViewGroup 中时,它会以与我的 ViewGroup 相同的动画展开,但我绝对不想要。
好吧,解释了很多(希望你能理解一半),但现在是我想要实现的目标。我想用一个动画师控制我的 ViewGroup,用另一位独立动画师控制所有子视图。
我有一种感觉,我的做法是错误的,所以如果有人有更简单/更好的建议,请这样做。
谢谢!
I have been having a lot of trouble lately trying to get my custom ViewGroup to animate (scale/translate animation) independently it's child views. Worth noting is that my custom ViewGroup is visible and not just a container, thus the need to animate it and not only it's children.
I want my ViewGroup to have 2 states, unexpanded and expanded with the former being able to display 1 view and the later being able to display that view in addition to 4 more (total 5).
The animation my ViewGroup uses to enter/exit the expanded state is done and i am very happy with it. Though when adding a View into the ViewGroup it to will expand with the same animation as my ViewGroup which i definitely do not want.
Ok, that was a lot of explaining (hope you understood half of it) but now comes what i want to achieve. I want to control my ViewGroup with one animator and all the child Views with another independent animator.
I have a feeling i am going at this the wrong way so if anyone has something easier/better to suggest than please do.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过使用 ValueAnimator 并对 ViewGroup 的 LayoutParams 进行动画处理解决了我的问题:)
I solved my problem by using a ValueAnimator and animating the LayoutParams of my ViewGroup :)