How to change the imageview's src as well as background programatically not in xml?
setBackgroundResource() : same behaviour as setBackground().
But in xml, we got the option to set the src as well as background.
Any help appreciated. Thanks.
How to change the imageview's src as well as background programatically not in xml?
setBackgroundResource() : same behaviour as setBackground().
But in xml, we got the option to set the src as well as background.
Any help appreciated. Thanks.
Below is the code
For Src:
img.setImageResource(R.drawable.icon);
For Background:
img.setBackgroundResource(R.drawable.icon);
Try setImageResource()
method:
.setImageResource(R.drawable.your_image);
Try this
imageView.setImageDrawable(ResourcesCompat.getDrawable(getResources(),R.drawable.imageID, null));