I'm trying to use a Nine Patch as a background for a Libgdx Scene2d UI button. It is loading, buts it is really ugly. I can see the "meta-data" pixels, and its being stretched as if it were just a regular image (the text on the button is "Continue"):
I'm loading the .9.png
files directly into a (libgdx) NinePatchDrawable
via a (libgdx) NinePatch
like this:
this.dialogButtonUp = new NinePatchDrawable(
new NinePatch(new Texture(Gdx.files.internal("data/button-round.9.png"))));
this.dialogButtonDown = new NinePatchDrawable(
new NinePatch(new Texture(Gdx.files.internal("data/button-round-down.9.png"))));
Then I make a TextButtonStyle
that describes the button, and references the two NinePatch
drawables:
TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle();
buttonStyle.font = aValidFontReally;
buttonStyle.fontColor = Color.BLACK;
buttonStyle.up = this.dialogButtonUp;
buttonStyle.down = this.dialogButtonDown;
buttonStyle.pressedOffsetX = -2;
I'm building the button indirectly, via a Dialog
box:
new Dialog( ... ).button("Continue", null, buttonStyle);
I've checked the .9.png
files to make sure that:
- that the asset files were refreshed in Eclipse
- that the meta-data border pixels are either fully-invisible or fully-visible-black
- that the Android
draw9patch
tool can load the images and verify them
Any other suggestions on what to check or change?
NinePatch.draw(...)
. So theDialog
andButton
are not botching it. – GrusNinePatch
is for the post-processed ones. Creating aTextureAtlas
looks like it will do the processing. I don't see any run-time support for ".9.png", but maybe I'm not looking in the right place yet ... – Grus