Archive for July, 2013

Guide: 9-Patch Tools and Explanation:

I think that 9-patch textures are underestimated in Android development and should be
used in almost everywhere while you developing a complex UI that should fit a lot of
screen sizes. But it’s really important first to fully understand how those 9-patch textures
work and how you use them to you advantage.

There is a lot of great material on the web to get the hang of it but I found this blog post
by Radley Marx really helpful for me to understand the needed concepts. If you haven’t read
it I strongly suggest you to do so. As simple as I can put it the 9-Patch textures are textures
that can stretch and be filled with content accordingly to guide lines that you add to the texture.
Those guide lines are removed when the texture is being applied and won’t show in your app.

Once you have understand the main concepts of creating a 9-Patch texture you will find that
adding a one pixel guide lines to a desired texture is not always as simple as it might seem.
I found my self something struggle to produce the desired texture that will stretch as I wanted.

Luckily I have found some tools on the web that will do this job for you:

1. The first tool is the Simple Nine-patch Generator from the Android Asset Studio.
Actually if you haven’t seen this page yet then I strongly suggest you to go over
Android Asset Studio there are really handy tools that you can use
in order to produce a Holo like textures with your desired color and much more.

2. The second tool is draw9patch.com. what I found convinient in this tool is
that you can see the result of the fill guide lines in the preview as well and you can see the
affect of the guide lines you change in real time.

Finally I would like to present you with a real life example where I used a 9-patch
to solve a UI design problem. This was a question I asked on SO and followed an answer
I received:

Is there a way to implement rounded corners to a Mapfragment?

That’s it for today, stay tuned.

July 23, 2013Emil Adjiev No Comments »
FILED UNDER :Guide , Guide - Android Development