Skip to content
This repository was archived by the owner on Nov 14, 2018. It is now read-only.
This repository was archived by the owner on Nov 14, 2018. It is now read-only.

Resources.Theme.resolveAttribute extension #587

@romtsn

Description

@romtsn

To facilitate the retrieving of an attribute from a theme, I'd like to propose the following extension:

inline fun Resources.Theme.resolveAttribute(
    resId: Int,
    resolveRefs: Boolean = true
): TypedValue = TypedValue().apply { resolveAttribute(resId, this, resolveRefs) }

So this will lead to the following change:

// before
val backgroundValue = TypedValue() 
context.theme.resolveAttribute(android.R.attr.selectableItemBackground, outValue, true)

// after
val backgroundValue = context.theme.resolveAttribute(android.R.attr.selectableItemBackground)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions