LayoutAnimationController

LayoutAnimationController

本文介绍了可以LayoutAnimationController动画只有特定浏览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能替代Android的只在某些特定子查看 s表示我指定的内部,这样的方式 LayoutAnimationController 一个的ViewGroup 将动画?我的目标是选择根据活动的当前状态任意一组儿童的意见,以同样的动画在完全相同的时间为它们制作动画,然后在以后的时间选择不同的任意一组儿童的意见和做同样的事情。我想是能够做到这一点不断,直到活动运行完毕。

Is it possible to override Android's LayoutAnimationController in such a way that only certain child Views that I specify inside a ViewGroup will animate? My goal is to choose an arbitrary set of the child views based on the current state of the Activity and animate them with the same animation at exactly the same time, then at a later time choose a different arbitrary set of child views and do the same thing. I would like to be able to do this continually until the Activity is finished running.

到目前为止,我已经看过,并驳回了几个选项:

So far I have looked at and dismissed a couple of options:

  1. 电话 startAnimation(动画)的具体子视图独立,但没有一个保证,他们将所有开始和结束在完全相同的时间,尤其是如果数意见中的任意集很大。
  2. 重写 LayoutAnimationController.getAnimationForView()似乎像这将是最简单的方法,但该方法是终局的,不能覆盖。
  1. Calling startAnimation(Animation) the specific child viewsindividually, however there is not a guarantee that they will allstart and end at exactly the same time, especially if the number ofviews in the arbitrary set is large.
  2. Overriding LayoutAnimationController.getAnimationForView() seemedlike it would be the easiest way, but the method is final and cannotbe overridden.

我一直在抓我的头有一段时间了这一点,并想我给堆栈溢出了一枪。

I have been scratching my head for some time on this and figured I would give Stack Overflow a shot.

推荐答案

我没能找到一种方法来改变Android的 LayoutAnimationController ,但没有拿出一个简单的解决方案,我想要做什么。我创建了一个查看子类,它可以选择性无视调用运行一个动画,如果我选择这样做。

I wasn't able to find a way to change Android's LayoutAnimationController, but did come up with a simple solution that does what I want. I created a View subclass that can selectively ignore calls to run an animation if I so choose.

public class AnimationAverseView extends View {

    private boolean mIsAnimatable = true;

    public void setAnimatible(boolean isAnimatable) {
        if (!isAnimatable) {
            clearAnimation();
        }
        mIsAnimatable = isAnimatable;
    }

    @Override
    public void startAnimation(Animation animation) {
        if (mIsAnimatable) {
            super.startAnimation(animation);
        }
    }
}

我不担心任何其他可能的动漫相关的方法,因为我只能通过 LayoutAnimationController 查看取值C>。

I did not worry about any other possible animation-related methods, since I only animate the Views via a LayoutAnimationController.

这篇关于可以LayoutAnimationController动画只有特定浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 12:00