0

Is there any way to animate changing of scale type in an ImageView? For example, I have the image with ImageView.ScaleType.CENTER_CROP, and I want to create an animation when the image inside animates to ImageView.ScaleType.FIT_CENTER. I saw the source code of ChangeImageTransform but I can't figure out how can I do that in my code.

nullbyte
  • 1,178
  • 8
  • 16
  • Have you tried this: http://stackoverflow.com/questions/37535954/animate-scaletype-centercrop-in-imageview – thyago stall Jan 09 '17 at 16:49
  • Oh, yes I have, but it didn't work for me. – nullbyte Jan 09 '17 at 16:51
  • the only way is to set `scaleType=matrix` and scale / translete the `Matrix` accordingly – pskink Jan 09 '17 at 21:48
  • @thyago Okay, it seems the first option works for me now. However, what if I want to animate scaling/translation of the `ImageView` using `ObjectAnimator`, does it affect the animation with `Matrix`? I want to use both of them at the same time. Let's say the matrix animation works with the image inside, I work with the real view. – nullbyte Jan 09 '17 at 23:15
  • so if you want `ObjectAnimator` then simply use `ObjectAnimator#ofObject(Object target, String propertyName, TypeEvaluator evaluator, Object... values)` where `values` are two or more `Rect` objects, `Rect` is the proffered type as there is a built-in `TypeEvaluator` for it – pskink Jan 10 '17 at 08:55
  • Yes, I know how to handle the matrix animation, but I don't get a desired behavior when I try to animate both the image matrix and bounds of the `ImageView`. To make it clear, I have two `ImageView`s and every one of them has a different position on the screen and scale type. First of all, I set the bounds of the first `ImageView` to the second, and from that point I start animating the second view to its final position on the screen. During this animation I'm also doing the matrix animation in order to change smoothly the scale types.And all that thing doesn't give me an appropriate result – nullbyte Jan 10 '17 at 21:12

0 Answers0