Class ScaleDrawable

All Implemented Interfaces:
Drawable.Callback

public class ScaleDrawable extends DrawableWrapper
  • Constructor Details

    • ScaleDrawable

      public ScaleDrawable(Drawable drawable, int gravity, float scaleWidth, float scaleHeight)
      Creates a new scale drawable with the specified gravity and scale properties.
      Parameters:
      drawable - the drawable to scale
      gravity - gravity constant (see Gravity used to position the scaled drawable within the parent container
      scaleWidth - width scaling factor [0...1] to use then the level is at the maximum value, or -1 to not scale width
      scaleHeight - height scaling factor [0...1] to use then the level is at the maximum value, or -1 to not scale height
  • Method Details

    • setGravity

      public void setGravity(int gravity)
    • setScaleWidth

      public void setScaleWidth(float scaleWidth)
    • setScaleHeight

      public void setScaleHeight(float scaleHeight)
    • draw

      public void draw(@NonNull Canvas canvas)
      Description copied from class: Drawable
      Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha).
      Overrides:
      draw in class DrawableWrapper
      Parameters:
      canvas - The canvas to draw into
    • onLevelChange

      protected boolean onLevelChange(int level)
      Description copied from class: Drawable
      Override this in your subclass to change appearance if you vary based on level.
      Overrides:
      onLevelChange in class DrawableWrapper
      Returns:
      Returns true if the level change has caused the appearance of the Drawable to change (that is, it needs to be drawn), else false if it looks the same and there is no need to redraw it since its last level.
    • onBoundsChange

      protected void onBoundsChange(@NonNull Rect bounds)
      Description copied from class: Drawable
      Override this in your subclass to change appearance if you vary based on the bounds.
      Overrides:
      onBoundsChange in class DrawableWrapper