AnimationDrawable not playing. Not called from onCreate

357 views Asked by At

This is really weired, it plays in Nexus 5, but in all other phones it doesn't work. Please see my code, it definitely doesn't start animation in onCreate.

I can see the first frame.

        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();
                }
            });
    }
0

There are 0 answers