diff options
| author | Andrey Kulikov <andreykulikov@google.com> | 2018-11-27 15:52:17 +0000 |
|---|---|---|
| committer | Andrey Kulikov <andreykulikov@google.com> | 2018-11-27 15:52:17 +0000 |
| commit | 3ac312acf0afa08af8f2bb5f25993de9453ab201 (patch) | |
| tree | c3742cb34a5d478845c83b132e611ef057650706 /core/java/android/widget/ImageView.java | |
| parent | 1c32bcc762725b956a8e2a50496dfce6d3911b5b (diff) | |
Made ImageView.animateTransform(Matrix) public
ImageView.animateTransform(Matrix) is now public so we can use it in AndroidX Transitions without a reflection.
Also I fixed a bug that we forgot to clear mDrawMatrix when we provide null matrix into a method. Before it doesn't work as expected if ImageView already calculated some draw matix and we wan't to override it.
Bug: 117521477
Test: Added new cts tests for both usages with null and not null matrix
Change-Id: I9e25e1f673fabdfeb227fabc0b3635056de0a6fd
Diffstat (limited to 'core/java/android/widget/ImageView.java')
| -rw-r--r-- | core/java/android/widget/ImageView.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/core/java/android/widget/ImageView.java b/core/java/android/widget/ImageView.java index 12cc54d7241e..41b4bd3d0a3e 100644 --- a/core/java/android/widget/ImageView.java +++ b/core/java/android/widget/ImageView.java @@ -1331,9 +1331,17 @@ public class ImageView extends View { } } - /** @hide */ - @UnsupportedAppUsage - public void animateTransform(Matrix matrix) { + /** + * Applies a temporary transformation {@link Matrix} to the view's drawable when it is drawn. + * Allows custom scaling, translation, and perspective distortion during an animation. + * + * This method is a lightweight analogue of {@link ImageView#setImageMatrix(Matrix)} to use + * only during animations as this matrix will be cleared after the next drawable + * update or view's bounds change. + * + * @param matrix The transformation parameters in matrix form. + */ + public void animateTransform(@Nullable Matrix matrix) { if (mDrawable == null) { return; } @@ -1341,6 +1349,7 @@ public class ImageView extends View { final int vwidth = getWidth() - mPaddingLeft - mPaddingRight; final int vheight = getHeight() - mPaddingTop - mPaddingBottom; mDrawable.setBounds(0, 0, vwidth, vheight); + mDrawMatrix = null; } else { mDrawable.setBounds(0, 0, mDrawableWidth, mDrawableHeight); if (mDrawMatrix == null) { |
