Android 9-patch is not recognized on the device

I just made nine patches

it is saved as border.9.png from the draw 9 patch tool.

in my Android layout editor, it looks as if it will be the correct graphics of 9 patches, stretched but not pixelated.

http://i39.tinypic.com/28bsi69.png

nevertheless, on a real device, it just shows a giant stretched image, with visible guides of 9 patches, it looks very bad

what's the matter??? and how can I fix it

my xml:

<LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/border" android:orientation="vertical" android:padding="35dip" > 
+7
source share
5 answers

You can find all the necessary information on how to create 9.patch here.

Your background should be like this

nine patch background

Note: the markers at the bottom and on the right should be drawn as complete lines, not individual points.

Edit
It seems that 9.patch download is changed here and can no longer be used as 9.patch.
You can download the functional version from here.

+6
source

I had the same problem: everything worked perfectly in Eclipse, but everything that was on the device. I solved this by opening PNG in the Draw 9-patch tool . Just open png and save it et voila!

+10
source

It looks like an invalid 9.ptach file for me. There should be solid areas below and to the right.

+4
source

As a last resort, whenever you find it difficult to find 9 patches that will be recognized as such, I find it always better to just make a BRAND NEW image file in your image creation software, copy everything except 4 1 -pixel for your source image, and then paste into a new image file. Sometimes, no matter how much you remove the 4 edges, the device / emulator still cannot recognize it as a 9-patch, although (and this probably should be due to the Android SDK dev command), this is perfectly normal 9-patch in Eclipse graphic layout.

Also note that black lines on the right and bottom edges are optional. They indicate "padding", in particular the area in which the content fits (a parent of a parent with a background of 9 patches).

+3
source

It took me a few hours to figure out why my ninth patch wasn’t right.

The reason was pretty simple. My nine patch images were saved:

 /res/drawable 

instead

 /res/drawable-xxx 
+1
source

Source: https://habr.com/ru/post/903622/


All Articles