getColorFromAttr

fun Context.getColorFromAttr(@AttrRes colorAttr: Int, defaultColor: Int = 0): Int

Creates a color from the given attribute, If the attribute references a color resource holding a complex android.content.res.ColorStateList, then the default color from the set is returned.

Return

Attribute color value, or defValue if not defined.

Parameters

colorAttr

attribute resource for color

Throws

if the attribute is defined but is not a color or drawable resource.