Object ScaleTypeTransform

  • All Implemented Interfaces:

    
    public class ScaleTypeTransform
    
                        

    Util methods for view size calculations

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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 scaling view inside its parent container.
      • 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 scaling view inside its parent container.
      • 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.