what is the meaning of ImageView.ScaleType="MATRIX" : Android

Mayur R. Amipara picture Mayur R. Amipara · Aug 3, 2015 · Viewed 18.4k times · Source

I know about the matrix, its structure and working about image view's scale-type. but,

  1. I can't find the exact meaning of ImageView.ScaleType="MATRIX". By declaring this, what exactly happens while drawing the image view.

  2. When can I use ImageView.ScaleType="MATRIX" ?

  3. 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.

Answer

bitsoverflow picture bitsoverflow · Aug 3, 2015
  1. 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.
  2. You can use imageView.setScaleType(ImageView.ScaleType.MATRIX) whenever you want to customize the way the your image scales, rotates, etc. at your desire.
  3. 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