Search code examples
androidnine-patch

android 9 patch doesn't work as I want


Picture showed bellow is my nine patch file. I just want to center the icon as the arrow point to.

enter image description here

I palced the nite patch file in xhdpi, my xml is like:

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/blue"
    android:orientation="vertical" >

    <Button
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:background="@drawable/kkkkkkkkkk" />

</LinearLayout>

And the preview is correct, the white icon is exactly placed in center. When I run this application, the result turned out to be like this:

enter image description here

If I placed this picture in hdpi or xxhdpi, the result is corret. I have no idea about this, could any one of you can help with this?

My test device is Galaxy Note3. Thank you :-)


Solution

  • add one more pixel to the top-right and left-bottom...and then see the result