简体   繁体   中英

Make KenBurnsView fit and fill given area

My App uses KenBurnsView (wonderful piece of code, thanks!), and it works well with ScaleType.FIT_CENTE mode, but some users just prefer to see the whole, non cropped image instead (non moving in that case), which works pretty well with standard ImageView, but fails miserably with KenBurns:

    if (XenoAmp.getWpsCover()) {
        final KenBurnsView caly = (KenBurnsView) widok.findViewById(R.id.tlo);
        if (XenoAmp.getCoverFill()) {
            caly.setScaleType(ScaleType.FIT_CENTER);
        } else {
            caly.setScaleType(ScaleType.CENTER_INSIDE);
            caly.pause();
        }
    }

What happens with Ken is: he stays small and sticks to upper left corner of parent view. How can I fix that without replacing it with standard ImageView?

You can take two different approaches:

  1. Use a standard ImageView together with KenBurnsView and switch visibilities according to what your users want to see.

  2. Write your own TransitionGenerator that doesn't do any transition at all. You can find some information about how to do it here: Define zoom/pan start position with KenBurnsView

IMO, the former approach is much simpler and makes more sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM