I'm trying to have an image (as the background) on a button and add dynamically, depending on what's happening during run-time, some text above/over the image.
If I use ImageButton
I don't even have the possibility to add text.
If I use Button
I can add text but only define an image with android:drawableBottom
and similar XML attributes as defined here.
However these attributes only combine text & image in x- and y-dimensions, meaning I can draw an image around my text, but not below/under my text (with the z-axis defined as coming out of the display).
Any suggestions on how to do this? One idea would be to either extend Button
or ImageButton
and override the draw()
-method. But with my current level of knowledge I don't really know how to do this (2D rendering). Maybe someone with more experience knows a solution or at least some pointers to start?
You can use this:
in that i have put an image as
background
and also added text..!just replace
with
izz a pretty good trick.. ;)
http://www.mokasocial.com/2010/04/create-a-button-with-an-image-and-text-android/
You can use
drawableTop
(alsodrawableLeft
, etc) for the image and set text below the image by adding thegravity
left|center_vertical