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.
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 TypeMethodDescriptionstatic ScaleStrategy
balanced()
static ScaleStrategy
fit()
Will zoom out until it is able to fit its preferred size.static ScaleStrategy
flexible()
Does not perform any scaling, and makes the canvas match the native screen resolution and aspect ratio.float
getZoomLevel
(Canvas canvas) static ScaleStrategy
scale()
Will try to match the preferred size, scaling the canvas if necessary.
-
Method Details
-
getZoomLevel
-
flexible
Does not perform any scaling, and makes the canvas match the native screen resolution and aspect ratio. -
scale
Will try to match the preferred size, scaling the canvas if necessary. This will generally produce better-looking results thanfit()
. 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
Will zoom out until it is able to fit its preferred size. Compared toscale()
, 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
-