Package icyllis.modernui.graphics.drawable

# Class Drawable.ConstantState

java.lang.Object
icyllis.modernui.graphics.drawable.Drawable.ConstantState

Direct Known Subclasses:
  `DrawableContainer.DrawableContainerState`

Enclosing class:
  `Drawable`

public abstract static class Drawable.ConstantState extends Object
This abstract class is used by `Drawable`s to store shared constant state and data between Drawables.

Use `Drawable.getConstantState()` to retrieve the ConstantState of a drawable. Calling `Drawable.mutate()` on a Drawable should typically create a new ConstantState for that Drawable.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ConstantState()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `canApplyTheme()`
  Return whether this constant state can have a theme applied.
  `int`
  `getChangingConfigurations()`
  Return a bit mask of configuration changes that will impact this drawable (and thus require completely reloading it).
  `abstract Drawable`
  `newDrawable()`
  Creates a new Drawable instance from its constant state.
  `Drawable`
  `newDrawable(Resources res)`
  Creates a new Drawable instance from its constant state using the specified resources.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ConstantState

    public ConstantState()

- ## Method Details

  - ### newDrawable

    @NonNull public abstract Drawable newDrawable()
    Creates a new Drawable instance from its constant state.

    Note: Using this method means density-dependent properties, such as pixel dimensions or bitmap images, will not be updated to match the density of the target display. To ensure correct scaling, use `newDrawable(Resources)` instead to provide an appropriate Resources object.

    Returns:
      a new drawable object based on this constant state
    See Also:
      - `newDrawable(Resources)`

  - ### newDrawable

    @NonNull public Drawable newDrawable(@Nullable Resources res)
    Creates a new Drawable instance from its constant state using the specified resources. This method should be implemented for drawables that have density-dependent properties.

    The default implementation for this method calls through to `newDrawable()`.

    Parameters:
      `res` - the resources of the context in which the drawable will be displayed
    Returns:
      a new drawable object based on this constant state

  - ### getChangingConfigurations

    public int getChangingConfigurations()
    Return a bit mask of configuration changes that will impact this drawable (and thus require completely reloading it).

  - ### canApplyTheme

    public boolean canApplyTheme()
    Return whether this constant state can have a theme applied.