【问题标题】:How can I move text to the next line if it exceeds the screen's width in Corona?如果文本超过 Corona 中的屏幕宽度,如何将文本移动到下一行?
【发布时间】:2012-06-24 17:11:21
【问题描述】:

如果文本超出屏幕宽度,我希望文本自动继续到下一行。我该怎么做?

例如,这个在 Android 屏幕上是超出的,我希望它在屏幕上完全显示。

local str=display.newText("HOSGELDINIZ",50,200,nil,70)

【问题讨论】:

  • 自己发布遮阳篷并接受它,这样人们就会看到这有遮阳篷:)

标签: text lua screen coronasdk


【解决方案1】:

我找到了答案。为了避免超出,我们需要再添加两个限制文本区域的参数。

就这样:

 local str=display.newText("HOSGELDINIZ",50,200,150,150,nil,70)

在高度和宽度位置之后,我们添加文本区域的宽度和高度,这样它就不会超出屏幕。

希望对你有用。

【讨论】:

    【解决方案2】:

    截至今天,使用 Corona 发送多行文本是在 options 内完成的。 这是一个简单的例子:

    display.newText({
            parent   = myParent,
            text     = "This is a long enough text to be on two lines",  
            width    = display.contentWidth*0.6,  
            height   = display.contentHeight*0.25,  
            x        = display.contentWidth*0.5,
            y        = display.contentHeight*0.5,
            fontSize = 24,
            align    = "center",
        })
    

    【讨论】:

      【解决方案3】:

      如果你只是想在一个新行上显示单个字符串,你可以使用下面的方法。

      local displayStr=display.newText(“this sample text can be split with \nto next line “, x, y, native.systemFont, fontSize)
      

      [注意文本中如何使用'\n'来分割字符串]

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-18
        • 1970-01-01
        • 2011-01-29
        • 1970-01-01
        • 2012-05-19
        • 1970-01-01
        相关资源
        最近更新 更多