对 ViewGroup 进行动画处理而不对子视图进行动画处理

发布于 2024-11-19 22:16:32 字数 443 浏览 2 评论 0原文

最近,我在尝试让自定义 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰雪梦之恋 2024-11-26 22:16:32

我通过使用 ValueAnimator 并对 ViewGroup 的 LayoutParams 进行动画处理解决了我的问题:)

I solved my problem by using a ValueAnimator and animating the LayoutParams of my ViewGroup :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文