Nifty text alignment being ignored

Greetings!



I’m having a slight problem with Nifty Gui. In a xml document which contains code for a basic gui, I have two lines of text. However only one is displayed correctly, the second one ignores my alignment and ends up in the top left corner. Here is the code:



[xml]

<?xml version=“1.0” encoding=“UTF-8”?>

<nifty xmlns=“http://nifty-gui.sourceforge.net/nifty.xsd

xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance

xsi:schemaLocation=“http://nifty-gui.sourceforge.net/nifty.xsd

http://nifty-gui.sourceforge.net/nifty.xsd”>



<screen id=“start” controller=“package.Main”>

<layer id=“layer1” backgroundColor="#003f" childLayout=“center”>

<panel height=“25%” width=“35%” align=“center” valign=“center” backgroundColor="#f60f" childLayout=“center” visibleToMouse=“true”>

<text font=“verdana-48-regular.fnt” text=“Hello World!” align=“left” valign=“center” />

<text font=“verdana-48-regular.fnt” text=“Hello World line 2!” align=“right” valign=“center” />

</panel>

</layer>

</screen>

</nifty>

[/xml]



It doesn’t matter what alignment I use for the second text, it just gets ignored.



I feel like I’m missing something obvious, so any help would be appreciated



cheers!

i could be wrong but i think here is the problem :



<panel height=“25%” width=“35%” align=“center” valign=“center” backgroundColor="#f60f" childLayout=“center” visibleToMouse=“true”>









well, but not sure myself since i m no good with nifty ^^



childLayout=“horizontal” could be of help



greetings

Terry

yeah, terry is correct. childLayout=“center” only cares about the very first element it will basically f*ck up all other elements :smiley:



I think Nifty really should add a warning in the log when it detects multiple child element for a childLayout=“center” element.



I’ve added the warning to Nifty svn now:



[java] if (elements.size() > 1) {

log.warning(“You’re using a centerLayout element but you’ve added more than one child element to it. centerLayout only supports one element! Odd things will happen when used with more than one element :)”);

}

[/java]