Tell me please. Before me is the task of dynamically changing the image when you click on the ImageView. This is essentially a like button. Clicked once, the picture changed to like, clicked another time, the picture changed to unlike and so on to infinity. Initially, the image from resources resides in imageView during initialization. Therefore, I decided that it was necessary to compare the image in ImageView and the image from resources. I decide this way:
if (imageViewLike.getDrawable().getConstantState().equals(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_favorite_border_black_18dp).getConstantState())){ imageViewLike.setImageResource(R.drawable.ic_favorite_black_18dp); } else {imageViewLike.setImageResource(R.drawable.ic_favorite_border_black_18dp); } in version 4.1.1 it works in 5.1 no.