I know about the matrix
, its structure and working about image view's scale-type. but,
I can't find the exact meaning of ImageView.ScaleType="MATRIX"
. By declaring this, what exactly happens while drawing the image view.
When can I use ImageView.ScaleType="MATRIX"
?
How does it differ from FIT_END
& FIT_START
I googled about it and also referred the official link but was not able to find the exact answer.
Displays image resources, for example Bitmap or Drawable resources. ImageView is also commonly used to apply tints to an image and handle image scaling.
ScaleType is used for uniformly scaling the image bounds to the ImageView. Android ImageView provides various types of ScaleType for different configurations. CENTER. CENTER_CROP. CENTER_INSIDE.
An ImageView control is used to display images in Android applications. An image can be displayed by assigning it to the ImageView control and including the android:src attribute in the XML definition of the control.
ImageView.ScaleType.MATRIX
lets you use a Matrix
to scale the image. You can set the Matrix using ImageView.setImageMatrix(matrix)
. So by declaring the scaleType to MATRIX you are saying that you want to use an explicit Matrix to do that.imageView.setScaleType(ImageView.ScaleType.MATRIX)
whenever you want to customize the way the your image scales, rotates, etc. at your desire.FIT_END
and FIT_START
are default types of scale. So, if you use FIT_END
for instance, your image will maintain the original aspect ratio and it will align the result of the right and bottom edges of your image view. So basically, the difference is that FIT_END
and FIT_START
are "presets" while with MATRIX
you declare that you want to use your own matrix to scale.Read the docs for more info
As per my understanding, Use below details for each ImageView's ScaleType attributes
center
Displays the image centered in the view with no scaling.
centerCrop
Scales the image such that both the x and y dimensions are greater than or equal to the view, while maintaining the image aspect ratio; crops any part of the image that exceeds the size of the view; centers the image in the view.
centerInside
Scales the image to fit inside the view, while maintaining the image aspect ratio. If the image is already smaller than the view, then this is the same as center.
fitCenter
Scales the image to fit inside the view, while maintaining the image aspect ratio. At least one axis will exactly match the view, and the result is centered inside the view.
fitStart
Same as fitCenter but aligned to the top left of the view.
fitEnd
Same as fitCenter but aligned to the bottom right of the view.
fitXY
Scales the x and y dimensions to exactly match the view size; does not maintain the image aspect ratio.
matrix
Scales the image using a supplied Matrix class. The matrix can be supplied using the setImageMatrix method. A Matrix class can be used to apply transformations such as rotations to an image.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With