如何在我的 FXML 文件中以多行布局文本并附加它们

How can I lay out text in multple lines in my FXML File and append them

在我的一个 FXML 文件中,我有一个看起来像这样的文本标签

 <TextFlow >
      <Text text="There are 15 questions standing between you and a million dollar pay day! Each question is presented in multiple choice format. One of the four choices is the correct answer - your job is to pick the right one! The questions become more difficult as you progress through the game, but the potential payoff increases as well! Miss a question and the game is over." id="gameText" fill="white"/>
 </TextFlow>

当我尝试像这样在多行中进行操作时

<TextFlow >
     <Text text="There are 15 questions standing between you and a million dollar pay day!
     Each question is presented in multiple choice format. One of the four choices is the 
     correct answer - your job is to pick the right one! The questions become more difficult
     as you progress through the game, but the potential payoff increases as well! Miss a 
     question and the game is over." id="gameText" fill="white"/>
</TextFlow>

用第二种方法我的输出结果是这样的(多行文本标签)

单条直线的文本标签给了我正确的输出,但我想知道是否有另一种方法可以使用第二种方法正确布局文本。

根据 here and here 的回答,在您的 XML 中使用 CDATA 可能是您所追求的解决方案。

<TextFlow>
    <Text  id="gameText" fill="white">
        <![CDATA[
            There are 15 questions standing between you and a million dollar pay day!<br />
            Each question is presented in multiple choice format. One of the four choices is the correct answer - your job is to pick the right one! The questions become more difficult as you progress through the game, but the potential payoff increases as well!<br />
            Miss a question and the game is over."<br />
        ]]>
    </Text>
</TextFlow>

这将在您的文本节点中带回 html 换行符,当由网络浏览器呈现时应该会给出您想要的结果