V
V
Vlad1612014-06-30 16:06:21
Android
Vlad161, 2014-06-30 16:06:21

How to work with 9Patch in libGDX?

I need to make a button with a stretchable background. I have a .9.png (nine patch) image file, but when I do this, the background is not stretched into nine patch , but just stretched like a picture and the quality is badly damaged. How to work in nine patch in libGDX? I checked this background in the Android SDK, everything works well there.

Drawable drawableButtonMessageUp = new TextureRegionDrawable(new TextureRegion(new Texture("data/message_my_g.9.png")));
    ButtonStyle buttonStyleMessage = new ButtonStyle();
    buttonStyleMessage.up = drawableButtonMessageUp;
    Button buttonMessage = new Button(buttonStyleMessage);
    Label labelMessage = new Label("", new LabelStyle(game.fonts[0], new Color(0, 0, 0, 1)));
    buttonMessage.add(labelMessage);

Here is what I get:
voPBi.png
Here is what I want:
lQESf.png
And here is the nine path picture itself:
KBJKB.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Marat S, 2014-06-30
@aratj

look at the libgdx doc
https://code.google.com/p/libgdx/wiki/GraphicsNinePatch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question