-1

enter image description here

I want to set icon on button on center place through programatically as the above diagram please any one help me...

Satheesh
  • 1,722
  • 25
  • 35

1 Answers1

3

May This helps you..

Set background image for button which is in Drawable folder then use below code:

btn.setBackgroundResource(R.drawable.image);

OR

btn.setBackgroundDrawable(getResources().getDrawable(R.drawable.image));

Or use: setCompoundDrawableWithIntrinsicBounds().

Look More Regarding setCompoundDrawableWithIntrinsicBounds() in its documentation : CLICK HERE

Edit:

Try this way: setCompoundDrawableWithIntrinsicBounds(R.drawables.minus,0,0,0);

Add this line in XML: android:paddingLeft="100dp"

Bhavin Nattar
  • 3,189
  • 2
  • 22
  • 30