mirror of
https://github.com/mihonapp/mihon.git
synced 2024-10-31 21:20:59 -04:00
20 lines
No EOL
620 B
Kotlin
20 lines
No EOL
620 B
Kotlin
package eu.kanade.tachiyomi.util
|
|
|
|
import android.support.annotation.DrawableRes
|
|
import android.support.graphics.drawable.VectorDrawableCompat
|
|
import android.support.v4.content.ContextCompat
|
|
import android.support.v4.graphics.drawable.DrawableCompat
|
|
import android.widget.ImageView
|
|
|
|
/**
|
|
* Set a vector on a [ImageView].
|
|
*
|
|
* @param drawable id of drawable resource
|
|
*/
|
|
fun ImageView.setVectorCompat(@DrawableRes drawable: Int, tint: Int? = null) {
|
|
val vector = VectorDrawableCompat.create(resources, drawable, context.theme)
|
|
if (tint != null) {
|
|
vector?.setTint(tint)
|
|
}
|
|
setImageDrawable(vector)
|
|
} |