views:

96

answers:

4

I want to have a button that has an image on top and some text on bottom. Both the image and text are decided during runtime, so I want to be able to combine ImageButton's setImageBitmap and Button's setText for each button.

Any ideas?

Thanks Chris

A: 

I don't think there is an easy way to do that.

I would create a custom-component.

Macarse
It's perfectly definable trough XML layout
ognian
@ognian: You can use a XML layout to define a custom-component.
Macarse
Yes, but I wanted to say that there is no need to create another subclass of View just to have a button with image and text
ognian
A: 

I finally found what I was looking for:

setCompoundDrawablesWithIntrinsicBounds lets me assign a bitmap/drawable for a Button, at the same time letting me use setText.

Chris
A: 

I'm not getting how to use "setCompoundDrawablesWithIntrinsicBounds"

can u help me out?? please...

karthik8687
A: 

For eg: To set a bitmap image on top of the button, do something like

button.setCompoundDrawablesWithIntrinsicBounds(null, new BitmapDrawable(bitmapimage), null, null);

Chris