Object ScaleTypeTransform
-
- All Implemented Interfaces:
public class ScaleTypeTransform
Util methods for view size calculations
-
-
Field Summary
Fields Modifier and Type Field Description public final static ScaleTypeTransform
INSTANCE
-
Method Summary
Modifier and Type Method Description final static Pair<Float, Float>
getFillScaleWithBufferAspectRatio(View view, 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. final static Pair<Float, Float>
getFitScaleWithBufferAspectRatio(View view, 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. final static Point
getOriginOfCenteredView(View container, View view)
Computes the top left coordinates for the view to be centered inside its parent. final static Integer
getRotationDegrees(View view)
Computes the rotation of a android.view.View in degrees from its natural orientation. final static Boolean
isNaturalPortrait(Context context, Integer rotationDegrees)
Determines whether the current device is a natural portrait-oriented deviceUsing 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. final static Integer
rotationDegreesFromSurfaceRotation(Integer rotationConstant)
Get the int value degree of a rotation from the Surface constants. -
-
Method Detail
-
getFillScaleWithBufferAspectRatio
final static Pair<Float, Float> getFillScaleWithBufferAspectRatio(View view, 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.
- Parameters:
view
- A target android.view.View which have to be scaled to the bufferSize.bufferSize
- A android.util.Size whose aspect ratio must be maintained when scalingview
inside its parentcontainer
.
-
getFitScaleWithBufferAspectRatio
final static Pair<Float, Float> getFitScaleWithBufferAspectRatio(View view, 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.
- Parameters:
view
- A target android.view.View which have to be scaled to the bufferSize.bufferSize
- A android.util.Size whose aspect ratio must be maintained when scalingview
inside its parentcontainer
.
-
getOriginOfCenteredView
final static Point getOriginOfCenteredView(View container, View view)
Computes the top left coordinates for the view to be centered inside its parent.
- Parameters:
container
- A parent android.view.View that wrapsview
.view
- A child android.view.View ofcontainer
.
-
getRotationDegrees
final static Integer getRotationDegrees(View view)
Computes the rotation of a android.view.View in degrees from its natural orientation.
-
isNaturalPortrait
final static Boolean isNaturalPortrait(Context context, Integer 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.
- Parameters:
context
- Current context.rotationDegrees
- The device's rotation in degrees from its natural orientation.
-
rotationDegreesFromSurfaceRotation
final static Integer rotationDegreesFromSurfaceRotation(Integer 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.
-
-
-
-