Lion Hanes
Lion Hanes

Reputation: 121

Libgdx 9-patch with multiple stretchable areas

9patch stretch and content areas

I use this 9patch in a simple game as dialog background in libgdx. I marked multiple stretchable areas for the fillet and sharp edges not to be stretched. Stretchable areas are on the left and top of the image. I also marked content area on the right and bottom of the image. But when i use it, libgdx ignores all the 9patch features and treat it like a simple Image.

How can I fix this problem?

Upvotes: 4

Views: 687

Answers (1)

P.T.
P.T.

Reputation: 25177

The Libgdx 9-patch only supports the nine basic patches. It does not support more complex patches (I didn't realize that was even possible with Android 9patch, but it seems to be). You can see the Libgdx code here: https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/graphics/g2d/NinePatch.java

The Libgdx NinePatch class doesn't even support the meta-data pixels. It expects those to be chopped off and converted by your TextureAtlas. See Loading nine-patch image as a Libgdx Scene2d Button background looks awful

Upvotes: 3

Related Questions