https://kotlinlang.org logo
#anko
Title
# anko
d

david.bilik

12/12/2017, 6:19 AM
we have created some extensions on View/Context to retrieving attribute resources eg. drawable
Copy code
/**
 * Get drawable defined by attribute [attr]
 */
fun Context.attrDrawable(attr: Int): Drawable {
    val a = theme.obtainStyledAttributes(intArrayOf(attr))
    val attributeResourceId = a.getResourceId(0, 0)
    a.recycle()
    return drawable(attributeResourceId)
}
s

spragg

12/12/2017, 10:37 PM
Thanks @david.bilik that is very useful.
3 Views