I have done this in an Activity and it works perfectly. ImageView myImage = (ImageView) findViewById(R.id.myImageView); ShapeDrawable mDrawable; …