EDIT: Sorry I realise from your comment my question was not clear enough. I will post a new one. Sorry for this and thanks for your answers
I am populat
Now as getDrawable
and setBackgroundDrawable
both are depricated
you should set drawable as Background like this :
view.setBackground(ContextCompat.getDrawable(this, R.drawable.your_drawable));
and if you are targating minSdk below 16 then make a check like this :
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
view.setBackgroundDrawable(ContextCompat.getDrawable(this, R.drawable.your_drawable));
} else {
view.setBackground(ContextCompat.getDrawable(this, R.drawable.your_drawable));
}
Here the new Method
recyclerView.setBackgroundResource(R.drawable.edit_text_button_shape);
don't use this it's an old method recyclerView.setBackgroundDrawable(this.getResources().getDrawable(edit_text_button_shape));
Try this
iv.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.img));
or
iv.setBackgroundResource(R.drawable.img);