flavioarfaria / KenBurnsView

Android ImageViews animated by Ken Burns Effect
Apache License 2.0
2.73k stars 435 forks source link

it doesn't work with fragment #44

Closed liaopen123 closed 8 years ago

liaopen123 commented 8 years ago

when I use KenBurnsView in Fragment , the animation doesn't work,How to solve it

narayanacharya6 commented 8 years ago

I have used it within a Fragment. Can you show a code snippet of what you have tried? You actually need to start the animation in the onCreateView() method and stop it in the onDestroy(). Something like this in a Fragment:

KenBurnsView image;
...
@Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_event_details, container, false);
        image = (KenBurnsView) view.findViewById(R.id.image);
        image.resume();
        return view;
    }
...
@Override
    public void onDestroy() {
        super.onDestroy();
        if (image != null) {
            image.pause();
        }
    }
...
liaopen123 commented 8 years ago

Thanks,It's my mistake,Now I have solved it.