在我的一个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>
我的输出结果与第二种方法(带有多行的文本标签)
一样
单个直线的文本标记为我提供了正确的输出,但我想知道是否有另一种方法可以使用第二种方法正确布局文本。
答案 0 :(得分:2)
根据here和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换行符,当Web浏览器呈现时,它会为您提供所需的结果