Interface ScaleStrategy

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ScaleStrategy
Determines how the Canvas should be scaled and zoomed when viewed on devices with different screen sizes, resolutions, and aspect ratios. This behavior is controlled by the zoom level. A zoom level of 1.0 indicates the canvas should be shown at its native size. Larger values will make the canvas appear "zoomed in", while smaller values will make the canvas appear "zoomed out".
  • Method Summary

    Modifier and Type
    Method
    Description
    Tries to find a balance between the behavior of fit() and scale().
    fit()
    Will zoom out until it is able to fit its preferred size.
    Does not perform any scaling, and makes the canvas match the native screen resolution and aspect ratio.
    float
     
    Will try to match the preferred size, scaling the canvas if necessary.
  • Method Details

    • getZoomLevel

      float getZoomLevel(Canvas canvas)
    • flexible

      static ScaleStrategy flexible()
      Does not perform any scaling, and makes the canvas match the native screen resolution and aspect ratio.
    • scale

      static ScaleStrategy scale()
      Will try to match the preferred size, scaling the canvas if necessary. This will generally produce better-looking results than fit(). The downside is the canvas might not fit within the screen bounds when the actual aspect ratio is different from the preferred aspect ratio.
    • fit

      static ScaleStrategy fit()
      Will zoom out until it is able to fit its preferred size. Compared to scale(), this ensures the entire canvas is visible at all times. The downside is that the canvas will appear extremely zoomed out when the actual aspect ratio is different from the preferred aspect ratio.
    • balanced

      static ScaleStrategy balanced()
      Tries to find a balance between the behavior of fit() and scale().