Android AnimationDrawable无法播放。未从onCreate调用

Android AnimationDrawable无法播放。未从onCreate调用,android,animation,animationdrawable,Android,Animation,Animationdrawable,这真的很奇怪,它在Nexus5中使用,但在所有其他手机中都不起作用。 请看我的代码,它肯定不会在onCreate中启动动画 我能看到第一帧 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_tiv, containe

这真的很奇怪,它在Nexus5中使用,但在所有其他手机中都不起作用。 请看我的代码,它肯定不会在onCreate中启动动画

我能看到第一帧

        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_tiv, container, false);
        final ImageView tv = (ImageView) rootView.findViewById(R.id.touchImageView1);
        tv.setImageDrawable(null);
        tv.postDelayed(new Runnable() {

            @Override
            public void run() {
                playAnimation(tv);
            }
        }, 2000);
        return rootView;
    }
        private void playAnimation(ImageView tv) {
            final AnimationDrawable little = ...;
            tv.setImageDrawable(little);
            little.setOneShot(false);
            tv.post(new Runnable() {

                @Override
                public void run() {
                    little.start();
                }
            });
    }

2秒的延迟似乎很危险,因为你不知道它会在多长时间内准备好。您是否尝试过从onAttach或onResume调用playAnimation?尝试过。最后我发现原因是你要先停下来。