Search code examples
androidnine-patch

9 patch not working correctly what i did wrong?


I did many search and I am really confused.

Here is my 9 patch file, result on device and XML of my button. Please tell me what's wrong about it

    <Button
    android:id="@+id/btnFlightInfo"
    android:layout_width="fill_parent"
    android:layout_height="110dp"
    android:background="@drawable/btntest1"
    android:layout_marginTop="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp"
    android:paddingRight="10dp"
    android:paddingTop="5dp"
    android:gravity="right|center_vertical"
    android:text="Flights"
    android:textColor="@color/white" 
    android:textStyle="bold"/>

nine patch file
enter image description here

result on android device
enter image description here


Solution

  • If this file is the picture in your project, you should save your picture with btntest1.9.png to specify at android this is a nine patch.