I have set an image to an ImageView
control in android:
iv.setImageResource(R.drawable.image1);
I want to get this associated Drawab
You can compare drawable resources like
if (imageView.getDrawable().getConstantState() ==
ContextCompat.getDrawable(getContext(), R.drawable.image1).getConstantState()) {
}
BitmapDrawables created from the same resource will for instance share a unique -bitmap stored in their ConstantState https://developer.android.com/reference/android/graphics/drawable/Drawable.ConstantState
getResources.getDrawable is deprecated so you can use ContextCompat.getDrawable inplace of it.