4i. Android: 9patch

If you want to provide a reach UI you will be using images, it is not possible to create image for every device size, therefore they will be stretching. Android 9patch is a way to control what can stretch in the image to preserve quality of that image.

Examples of using 9patch:





Finding draw9patch tool 



In the browser search for square icon




  • top - stretch horizontally
  • left - stretch vertically
  • right - content area
  • bottom - content area





Actual look of the 9patch:



Copy your 9patch  pop_up_background_82x82.9.png to drawable folder:

conventer/src/main/res/drawable-mdpi/pop_up_background.9.png


    <TextView
            android:id="@+id/resultingValue"
            android:text="..."
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="60"
            android:background="@drawable/pop_up_background" />




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