0

I am making an application for android that has some buttons like the picture I attached, these buttons are a ImageButton with GradientDrawable (button.setBackgroundDrawable (gd);) to the picture frame and button.setImageBitmap (bp); which is the image to start the application fee and finally got a button.setBackgroundColor (Color.TRANSPARENT); for the background color.

Link image:

enter image description here

My question is, is there any way for me to stay button in the same way as in the attached picture but with a text on the button? Is that the ImageButton has no option to add text and should use simple Button but does not support this button to put these four characteristics and stay as in the photo. In the end what I try to achieve is a button closest thing to the photo I attached but with a text in the middle.

Deputy code I use to put the image and design of the button.

final ImageButton button = new ImageButton(this);
button.setBackgroundColor(Color.TRANSPARENT);
button.setImageBitmap(bp);

button.setAdjustViewBounds(true);
button.setId(contador);
button.setBackgroundDrawable(gd);
Blackbelt
  • 156,034
  • 29
  • 297
  • 305
D.Mobi
  • 21
  • 2

2 Answers2

0

ImageButton don't support text adding, instead you can use Button and set its Background with an image and text.

take a look at this topic : Set the text in ImageButton

Community
  • 1
  • 1
ZAIRI Oussama
  • 745
  • 9
  • 13
0

In the end, I put a TextView with setCompoundDrawablesWithIntrinsicBounds property and a drawable on top and the text on the bot

D.Mobi
  • 21
  • 2