Search code examples
androidandroid-vectordrawable

setBackgroundResource programmatically for vector drawables


I have an Imageview in which I have to set a background image from my adapter. Using app:srcCompat in the xml code makes the image appear as it should. However, what should I do if I have to do the same thing programmatically?


Solution

  • To get the srcCompat effect programmatically on your imageview use the setImageResource method