ResourcesCompat

public final class ResourcesCompat


Helper for accessing features in Resources.

Summary

Nested types

ResourcesCompat.FontCallback

Interface used to receive asynchronous font fetching events.

ResourcesCompat.ThemeCompat

Provides backward-compatible implementations for new Theme APIs.

Constants

static final @AnyRes int

The null resource ID.

Public constructors

Public methods

static void

Clears cached values associated with the specified Theme.

static @Nullable Typeface
getCachedFont(@NonNull Context context, @FontRes int id)

Returns a cached font Typeface associated with a particular resource ID.

static @ColorInt int
getColor(
    @NonNull Resources res,
    @ColorRes int id,
    @Nullable Resources.Theme theme
)

Returns a themed color integer associated with a particular resource ID.

static @Nullable ColorStateList
getColorStateList(
    @NonNull Resources res,
    @ColorRes int id,
    @Nullable Resources.Theme theme
)

Returns a themed color state list associated with a particular resource ID.

static @Nullable Drawable
getDrawable(
    @NonNull Resources res,
    @DrawableRes int id,
    @Nullable Resources.Theme theme
)

Return a drawable object associated with a particular resource ID and styled for the specified theme.

static @Nullable Drawable
getDrawableForDensity(
    @NonNull Resources res,
    @DrawableRes int id,
    int density,
    @Nullable Resources.Theme theme
)

Return a drawable object associated with a particular resource ID for the given screen density in DPI and styled for the specified theme.