0

I have quite a few buttons in my application, they vary in sizes based on the text inside. I want to customize the buttons but I am not sure if I should use

A) Ninepatch pngs

B) Android xml created

C) Photoshop pngs

I want the buttons to scale nicely and therefore not look distorted based on screen size. What are the positives and negatives of the above methods? Is there an ideal way to go about this?

1 Answer 1

1

It depends on what they should look like. Rounded corners? Complicated images? Drop shadows? Plain colors?

If you want simple buttons that are monotone in color, xml drawables are the best solution. You can do rounded corners through xml, so if plain is what you are looking for this is the best option.

If you are working with an image, then a 9 patch is the way to go. Play around with the draw9patch tool that comes with the sdk to get the hang of it. You also don't necessarily only need to leave the corners in tack, sometimes you may want to break up the resizable area depending on the image.

PNGs are the last resort as they are the least flexible of the 3 options.

By the way, you should also consider using a state list for all of your buttons, regardless of how you implement the drawable that the button uses. See the link below:

http://developer.android.com/guide/topics/resources/drawable-resource.html#StateList

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the thorough answer!
@JamesFazio np, you can also put together some pretty nice drawables using a combination of nine patches and xml shapes using Layer Lists. developer.android.com/guide/topics/resources/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.