Search code examples
androidnine-patch

using nine-patch image as Background of Button android


I have created the following Nine-Patch PNG Image

enter image description here

but when I add it as a background for a button I have got the following result :

enter image description here

as you can see the picture not fill all the button Background !

here is the XML Layout File :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <Button
        android:id="@+id/btn"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="@drawable/ninepatchimage"
        android:text="Click ME" />
</LinearLayout>

can any one tell me why ??


Solution

  • Looking at the image it appears that the image ins't being parsed as a 9patch, it should be saved as img.9.png if not it will appear as a normal image

    Like this:

    enter image description here