Calling setCompoundDrawables() doesn't display the Compound Drawable
Use This (I tested). It works good
Drawable image = context.getResources().getDrawable( R.drawable.ic_action );int h = image.getIntrinsicHeight(); int w = image.getIntrinsicWidth(); image.setBounds( 0, 0, w, h );button.setCompoundDrawables( image, null, null, null );
Image is blank because it hasn't got specified bounds. You may use setCompoundDrawables()
but before you should specify image's bounds, using Drawable.setBounds()
method