Android: creating 9-patch image


This tutorial shows how to create a stretchable 9patch image on Mac OS. 



Step 1) 
Prepare some cool image to practice on.
Find on Internet (bad designer), or draw a button background image you really like:


Step 2)
Download Android SDK
http://developer.android.com/sdk/index.html



Step 3)
Install the Android SDK in your preferred location,  for me it is in:

example: $ /Applications/Android/adt-bundle-mac-x86_64-20130522/sdk/




Step 4) 
Add Android SDK tools to your system PATH

4.1 Open Terminal by: 
Open Launchpad and type in search "ter" and select Terminal




4.1 Edit your .profile
In Terminal type $ edit ~/.profile 
This should open default editor in my case TextWrangler with .profile 

4.2 Add following lines on the bottom adjusted for your installation directory

export ANDROID_HOME=/Applications/Android/adt-bundle-mac-x86_64-20130522/sdk/
export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools




4.3 Save file 
4.4. To refresh system, open NEW Terminal window by pressing on Terminal and click "command n"
see if you can see correct tool
$ which draw9patch

/Applications/Android/adt-bundle-mac-x86_64-20130522/sdk//tools/draw9patch

SUCCESS!

Step 5)
Open 
draw9patch tool by typing
$ draw9patch




Step 3) drag the image to the draw9patch tool and try to draw pixels on the edges of the image
  • left and top edges are for stretching areas
  • right and bottom are for (text) content area



actual 9patch file when saved, notice the file has name.9.png name and keep the 9 part:


final result




example with VERTICALLY non-stretchable image:



    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/textView1"
        android:layout_below="@+id/textView1"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="44dp"
        android:background="@drawable/back_button_normal"
        android:gravity="left|top"
        android:text="Good, this is what we wanted! :)"
        android:textColor="#CCCCCC" />






When you are working with images that have non-stretchable elements in them, you might define 2 stretching points. Also, it is a good practice to define a STYLE GUIDE if you need to create a set of 9patch images as in the case below:


  • left 16 (upper stretch)
  • left 26 (lower stretch)
  • right 9 (upper edge of text)
  • right 33 (lower edge of text)
  • bottom 8 (left margin)
  • bottom 16 (right margin, before arrow)
  • top 15 (any pixel inside text area)


Example with 2 stretchable areas


Enlarge and study the image.

You can see in the image above that I count 16 pixels on the left so the stretch is always in the same point of the bevel. I try to avoid stretching such images with bevel and create them "to size" vertically.

I leave 8 pixels as the margin on the left, and 4 pixels from the drop-down arrow which cannot stretch.
I leave 9 pixels from the top and bottom because in other images of this set I have rounded corners.

You can visualize the final image after stretching on the right-hand side (image in the middle).

Make sure to +1 our Google Developers Group page:


Shameless plug:
Visit my company website CyberWalkAbout.com for example of great work we have done and inquire about very competitive (low) rates of design and development we offer at info@CyberWalkAbout.com




As an Amazon Associate I earn from qualifying purchases.

Android Market Enigma

I have deployed "SF Bay Area Local Guide" over 24 hours ago and I got few downloads, yet the app is not showing on either Web Android Market, nor mobile version for any device I own.

Any suggestions?





As an Amazon Associate I earn from qualifying purchases.

Android ADT 14 Declares War on My Code!

The error comes up only when compiling the project, it started happening when I updated tools in Eclipse to ADT 14, but others had it in prior versions.

Unable to execute dex: Multiple dex files define

Conversion to Dalvik format failed with error 1
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/cyberwalkabout/common/DistanceUtils;




We have been using multiple project libraries for months, but now including them causes a problem as some of them are referenced more than once. 



SOLUTION is listed here: http://ukitech.blogspot.com/2012/06/javalangillegalargumentexception.html




Other problems encountered:

Updates (Android ADT 14) in Eclipse Indigo that introduced these problems:










switch() to if-then



Among many, many things that went wrong today this one was was annoying because of many places I had to change, but at least quick to fix.

Android ADT 14 decided that it does not like to use R.id.reference as a parameter to switch statement and it had to me changed to if-then.



So all of the switch statements had to be converted to if-then. Thankfully there is a shortcut for that (command-1).







As an Amazon Associate I earn from qualifying purchases.

720AM WGN The Voice Of Chicago covers Taxi Share


'With three touches to your phone, you'll get to where you need to be with fellow passengers.' 

Taxi Share Chicago App


Steve and Johnnie visit with Dan Foder, one of the co-creators of the Taxi Share Chicago app which allows you to meet / communicate / coordinate with other folks looking to share a cab.



http://www.wgnradio.com/shows/stevejohnnie/wgnam-sj-taxi-share-chicago,0,2436828.mp3file


As an Amazon Associate I earn from qualifying purchases.

Haplogroup R1b1b2a1a1d1


Subclade R1b1b2a1a1d1* (23andMe.com nomenclature) or R1b1a2a1a1a4 (FTDNA nomenclature) is a men linage descended from the region that was a land flooded by the North Sea.

R1b1b2a1a1d1 are members of R1b1b2a1a1d that test positive for L47.

The group is associated with Anglo-Saxons who invaded Britain following the Roman withdrawal in the fifth century AD. Frisiavones/Frisians who came to England with the Romans as part of the XX Legion.

This designation has been confirmed by "SNP" DNA testing that has yielded positive results for its defining mutations U106, L48 & L47.

Family name, Wiebe, originated in Friesland, Denmark; all tested males in 16 separate families are R1b1b2a1a1d1*. Wiebe is a common surname among Dutch Anabaptists who migrated from Holland to Prussia, Russia, and ultimately to the United States and Canada.

Oldest known common ancestor of R1b1b2a1a1d1* William Cloud, b. 1502. , of Wiltshire, England lived in central England, early instances of the Cloude name mention Robert atte CLOUDE, who was documented in County Somerset during the reign of Edward III (1327-1377) and Richard CLODE appears at the same time. Descendant, William Acree of Hanover Co., Virginia (the "Virginia Acrees") emigrated to the American colonies in 1682 with William Penn.

SNP L47 has been identified as a SNP located immediately downstream of L48. Individuals who are L48 positive but negative for all other downstream SNPs are currently classified as R1b1b2a1a1d. However, the recent discovery of L47 allows further classification of R1b1b2a1a1d individuals into R1b1b2a1a1d1.

Horobin family reports a line going back to 1430's in Staffordshire, England.

If you are member of this subclade and you know the place from where your ancestors hail, write to me and join our Facebook group:

http://www.facebook.com/groups/137690483032802/











As an Amazon Associate I earn from qualifying purchases.

Haplogroup H6a1


I just found out that I belong to haplogroup H6a1

My mothers ancestors lived in region of Kasina Wielka, southern Poland for at least 6 generations.

If you belong to this haplogroup, please write me about where your ancestors lived and I will put it on the Google Map.


Haplogroup H6a1:
http://maps.google.com/maps/ms?ie=UTF&msa=0&msid=212651556238973909980.0004af568b0817362d00f



As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles