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

后端 未结 4 1996
谎友^
谎友^ 2021-02-07 08:03

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

相关标签:
4条回答
  • 2021-02-07 08:50
    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

    0 讨论(0)
  • 2021-02-07 08:51

    The documentation you linked to provides the answer you are looking for.

    Scale using the image matrix when drawing. The image matrix can be set using setImageMatrix(Matrix). From XML, use this syntax: android:scaleType="matrix"

    Although you mentioned that you already know what a Matrix is in the context of graphics, I will explain briefly for the sake of other users who come across this question- A matrix can be used to manipulate the canvas when drawing graphics. In the case of an ImageView's matrix, you can use it to translate, flip, rotate, or otherwise move the image around on the screen.

    when i can use ImageView.ScaleType="MATRIX"

    You can use it whenever you want with an ImageView. You can call setScaleType() in your Java code to use a matrix scale type or you can add the android:scaleType="matrix" attribute in your layout XML.

    how it differs from FIT_END & FIT_START

    FIT_END and FIT_START both actually use a Matrix to scale your image. Both maintain the original aspect ratio and fit the image entirely within the view, but just align the result differently. End will align the scaled image to the end of the ImageView, whereas start will align the scaled image to the start of the ImageView

    0 讨论(0)
  • 2021-02-07 09:01

    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.

    0 讨论(0)
  • 2021-02-07 09:05

    ScaleType="MATRIX"

    A Matrix is constructed and scaled based on the user’s pinch gesture scale factor and then the ImageView set based on this scaled Matrix. Please visit here Android ImageView ScaleType

    Check the Effect.And https://guides.codepath.com/android/Working-with-the-ImageView

    0 讨论(0)
提交回复
热议问题