Android Question Buttons with images on them?

Jimdriver2

Member
Licensed User
Longtime User
On my app I need to have some large buttons that have images in the center and then a set colour for the rest of the button.

When changing buttons in the Designer I can only see options for setting a button colour or putting an image on the button and making the rest of it transparent (if the image is small.)

I've tried searching for threads and guides on buttons but couldn't find something. It could be I've not understood something fundamental about GUI controls, or maybe there is a library that I need to have and I don't know about it.

Any help would be much appreciated. Thanks.
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Most of the GUI objects have a .Background property. This can contain various items for example, a ColorDrawable, a BitmapDrawable or StatelistDrawable. Search these forums and the Beginner's Guide for these terms and you should get a good idea on how to proceed.
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
New
On my app I need to have some large buttons that have images in the center and then a set colour for the rest of the button.

if you choose bitmap, there is no way you can choose color as well, maybe play around the gravity.


You can however, create the image with the colored background for NORMAL STATE and PRESSED STATE to your desired size.

In the designer, under button properties - Choose statelist Drawable. Where it says Enable - choose bitmap drawable and select your normal image
Do same for PRESSED state and choose the pressed image you designed.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…