-1

This is the code used to generate the button

Button delBtn = new Button(activity);
LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
delBtn.setLayoutParams(params); 
delBtn.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.ic_action_cancel, 0);
delBtn.setBackgroundColor(Color.rgb(208, 0, 0));

Result Looks like this:

enter image description here

Whereas I expect:

enter image description here `
What is it that I missed?

Hamid Shatu
  • 9,664
  • 4
  • 30
  • 41
ranjjose
  • 2,138
  • 1
  • 24
  • 46

3 Answers3

0

You can use Imageview for this purpose as button has some padding value. And if the image has a background, you can make it transparent by:

imageButton.setBackgroundColor(android.R.color.transparent);
Sushil
  • 8,250
  • 3
  • 39
  • 71
0

You can try this:

  • Try Using ImagView instead of Button.
  • Set your image in "src" attribute.
  • Set background null/transperant.
Sagar Shah
  • 4,272
  • 2
  • 25
  • 36
0

As, suggested by Mansi (as comment, above), a simple TextView did the work!

ranjjose
  • 2,138
  • 1
  • 24
  • 46