在Corona .lua中填充父容器

在 corona 中是否有与 Android 中的 fill_parentwrap_content 相似的功能?这样它就可以适应每个屏幕方向中的背景图像。或者它有不同的方法来做到这一点。

提前致谢。

点赞
用户1502079
用户1502079

因为在 Corona 中没有 wrap_content,你没有 view groups,但是你可以通过模拟实现 wrap_content。此外,还有文本模块可以帮助你,可查看 http://developer.coronalabs.com/code/

是的,你可以在每个屏幕方向中实现 fill_parent

local W = display.contentWidth
local H = display.contentHeight
local background

local function drawInterface()
    background = display.newRect(0, 0, W, H)
    background.x = display.contentCenterX
    background.y = display.contentCenterY
    background:setFillColor(99, 165, 204)
end

drawInterface()

local function removeInterface()
    if background then background:removeSelf() end
end

local function onOrientationChanged (event)
    print("orientation changed")
    W = display.contentWidth
    H = display.contentHeight

    removeInterface()
    drawInterface()
end

Runtime:addEventListener("orientation", onOrientationChanged )
2013-05-08 16:09:20