Find draw9path. bat in the tools directory under the android SDK installation path and double-click to run it. Create a 9path image.
Layout. xml
<? XML version = "1.0" encoding = "UTF-8"?>
<Linearlayout xmlns: Android = "http://schemas.android.com/apk/res/android"
Android: layout_width = "fill_parent" Android: layout_height = "fill_parent"
Android: Orientation = "vertical">
<Button Android: text = "normal image as button background" Android: textsize = "20dip"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: Background = "@ drawable/myselectora"/>
<Button Android: text = "9patch image as button background" Android: textsize = "20dip"
Android: layout_width = "wrap_content" Android: layout_height = "wrap_content"
Android: Background = "@ drawable/myselectorb"/>
</Linearlayout>
The background of the second button is a 9patch image, which is stretched as follows: