public class ScaleTypeTransform
Util methods for view size calculations
public static ScaleTypeTransform INSTANCE
Util methods for view size calculations
@JvmStatic
@NotNull
public static android.util.Pair<java.lang.Float,java.lang.Float> getFillScaleWithBufferAspectRatio(@NotNull
android.view.View container,
@NotNull
android.view.View view,
@NotNull
android.util.Size bufferSize)
Computes the scale by which a view has to scale in x and y in order to fill its parent while maintaining the buffer's aspect ratio.
container - A parent android.view.View that wraps view.view - A child android.view.View of container.bufferSize - A android.util.Size whose aspect ratio must be maintained whenscaling view inside its parent container.view has to scale in x and y in order to fill its
parent while maintaining bufferSize's aspect ratio.@JvmStatic
@NotNull
public static android.util.Pair<java.lang.Float,java.lang.Float> getFitScaleWithBufferAspectRatio(@NotNull
android.view.View container,
@NotNull
android.view.View view,
@NotNull
android.util.Size bufferSize)
Computes the scale by which a view has to scale in x and y in order to fit its parent while maintaining the buffer's aspect ratio.
container - A parent android.view.View that wraps view.view - A child android.view.View of container.bufferSize - A android.util.Size whose aspect ratio must be maintained whenscaling view inside its parent container.view has to scale in x and y in order to fit its
parent while maintaining bufferSize's aspect ratio.@JvmStatic
@NotNull
public static android.graphics.Point getOriginOfCenteredView(@NotNull
android.view.View container,
@NotNull
android.view.View view)
Computes the top left coordinates for the view to be centered inside its parent.
container - A parent android.view.View that wraps view.view - A child android.view.View of container.view when centered inside its parent.@JvmStatic
public static int getRotationDegrees(@NotNull
android.view.View view)
Computes the rotation of a android.view.View in degrees from its natural orientation.
@JvmStatic
public static boolean isNaturalPortrait(@NotNull
android.content.Context context,
int rotationDegrees)
Determines whether the current device is a natural portrait-oriented device
Using the current app's window to determine whether the device is a natural portrait-oriented device doesn't work in all scenarios, one example of this is multi-window mode. Taking a natural portrait-oriented device in multi-window mode, rotating it 90 degrees (so that it's in landscape), with the app open, and its window's width being smaller than its height. Using the app's width and height would determine that the device isn't naturally portrait-oriented, where in fact it is, which is why it is important to use the size of the device instead.
context - Current context. Can be an android.app.Application contextor an android.app.Activity context.rotationDegrees - The device's rotation in degrees from its natural orientation.@JvmStatic public static int rotationDegreesFromSurfaceRotation(int rotationConstant)
Get the int value degree of a rotation from the Surface constants.
Valid values for the relative rotation are Surface.ROTATION_0, Surface.ROTATION_90, Surface.ROTATION_180, Surface.ROTATION_270.