public static interface

ScalingUtils.ScaleType

com.facebook.drawee.drawable.ScalingUtils.ScaleType
Known Indirect Subclasses

Class Overview

Options for scaling the child bounds to the parent bounds.

Similar to android.widget.ImageView.ScaleType, but ScaleType.MATRIX is not supported. To use matrix scaling, use a MatrixDrawable. An additional scale type (FOCUS_CROP) is provided.

Summary

Fields
public static final ScalingUtils.ScaleType CENTER Performs no scaling.
public static final ScalingUtils.ScaleType CENTER_CROP Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
public static final ScalingUtils.ScaleType CENTER_INSIDE Scales the child so that it fits entirely inside the parent.
public static final ScalingUtils.ScaleType FIT_BOTTOM_START Scales the child so that it fits entirely inside the parent.
public static final ScalingUtils.ScaleType FIT_CENTER Scales the child so that it fits entirely inside the parent.
public static final ScalingUtils.ScaleType FIT_END Scales the child so that it fits entirely inside the parent.
public static final ScalingUtils.ScaleType FIT_START Scales the child so that it fits entirely inside the parent.
public static final ScalingUtils.ScaleType FIT_XY Scales width and height independently, so that the child matches the parent exactly.
public static final ScalingUtils.ScaleType FOCUS_CROP Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent.
Public Methods
abstract Matrix getTransform(Matrix outTransform, Rect parentBounds, int childWidth, int childHeight, float focusX, float focusY)
Gets transformation matrix based on the scale type.

Fields

public static final ScalingUtils.ScaleType CENTER

Performs no scaling. Child is centered within parent's bounds.

public static final ScalingUtils.ScaleType CENTER_CROP

Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent. At least one dimension (width or height) will fit exactly. Child is centered within parent's bounds.

public static final ScalingUtils.ScaleType CENTER_INSIDE

Scales the child so that it fits entirely inside the parent. Unlike FIT_CENTER, if the child is smaller, no up-scaling will be performed. Aspect ratio is preserved. Child is centered within parent's bounds.

public static final ScalingUtils.ScaleType FIT_BOTTOM_START

Scales the child so that it fits entirely inside the parent. At least one dimension (width or height) will fit exactly. Aspect ratio is preserved. Child is aligned to the bottom-left corner of the parent.

public static final ScalingUtils.ScaleType FIT_CENTER

Scales the child so that it fits entirely inside the parent. At least one dimension (width or height) will fit exactly. Aspect ratio is preserved. Child is centered within the parent's bounds.

public static final ScalingUtils.ScaleType FIT_END

Scales the child so that it fits entirely inside the parent. At least one dimension (width or height) will fit exactly. Aspect ratio is preserved. Child is aligned to the bottom-right corner of the parent.

public static final ScalingUtils.ScaleType FIT_START

Scales the child so that it fits entirely inside the parent. At least one dimension (width or height) will fit exactly. Aspect ratio is preserved. Child is aligned to the top-left corner of the parent.

public static final ScalingUtils.ScaleType FIT_XY

Scales width and height independently, so that the child matches the parent exactly. This may change the aspect ratio of the child.

public static final ScalingUtils.ScaleType FOCUS_CROP

Scales the child so that both dimensions will be greater than or equal to the corresponding dimension of the parent. At least one dimension (width or height) will fit exactly. The child's focus point will be centered within the parent's bounds as much as possible without leaving empty space. It is guaranteed that the focus point will be visible and centered as much as possible. If the focus point is set to (0.5f, 0.5f), result will be equivalent to CENTER_CROP.

Public Methods

public abstract Matrix getTransform (Matrix outTransform, Rect parentBounds, int childWidth, int childHeight, float focusX, float focusY)

Gets transformation matrix based on the scale type.

Parameters
outTransform out matrix to store result
parentBounds parent bounds
childWidth child width
childHeight child height
focusX focus point x coordinate, relative [0...1]
focusY focus point y coordinate, relative [0...1]
Returns
  • same reference to the out matrix for convenience