【问题标题】:Corona newScrollView hideScrollBar still displays scroll barCorona newScrollView hideScrollBar 仍然显示滚动条
【发布时间】:2014-08-20 22:32:55
【问题描述】:

我这样声明滚动视图:

sv = widget.newScrollView{
    top = properties.y,
    left = properties.x,
    width = properties.moreGamesPanelWidth,
    height = properties.height,
    scrollWidth = properties.moreGamesPanelWidth,
    scrollHeight = lg.contentHeight,
    hideBackground = true,
    isBounceEnabled = false,
    horizontalScrollDisabled = true,
    isLocked = lock,
    listener = widgetTouchListener,
    hideScrollBar = true,
}

不幸的是,无论我在“hideScrollBar”中设置什么,滚动条仍然可见。 有没有可能隐藏滚动条?

【问题讨论】:

  • 这应该可以工作 - 您是否按照实现的方式粘贴它?我可以看到末尾有一个逗号(,),它不应该在那里?你在发布之前编辑过一些东西吗?
  • 就是这样。我总是把逗号放在最后,所以我可以在不编辑前一行的情况下添加元素。

标签: android ios lua coronasdk


【解决方案1】:

我发现了一个问题! 当您声明两个或多个滚动视图时会发生这种情况。它们中的最后一个覆盖了“hideScrollBar”设置。所以没有选择有两个滚动视图,一个有滚动条,一个没有滚动条。

这是证明问题的代码

properties.lua

local properties = {}

--device dimensions
properties.width = display.contentWidth + display.screenOriginX * -2
properties.height = display.contentHeight + display.screenOriginY * -2
properties.x = display.screenOriginX
properties.y = display.screenOriginY
properties.center = { x = properties.x + properties.width / 2, y = properties.y + properties.height / 2 }

return properties

main.lua

display.setStatusBar( display.HiddenStatusBar )


local properties = require("properties")
local widget = require("widget")

local sceneGroup = display.newGroup()

local lg = display.newGroup()
local lg2 = display.newGroup()

local bg = display.newRect(properties.center.x, properties.center.y, properties.width, properties.height)
bg:setFillColor(0.2, 0.2, 0.1)
sceneGroup:insert(bg)
local menuRect1 = display.newRect(100, 50, 200, 100)
menuRect1:setFillColor(0.8, 0.1, 0.1)
lg:insert(menuRect1)
local menuRect2 = display.newRect(100, 160, 200, 100)
menuRect2:setFillColor(0.1, 0.1, 0.9)
lg:insert(menuRect2)


local menuRect11 = display.newRect(100, 50, 200, 100)
menuRect11:setFillColor(0.8, 0.1, 0.1)
lg2:insert(menuRect11)
local menuRect22 = display.newRect(100, 160, 200, 100)
menuRect22:setFillColor(0.1, 0.1, 0.9)
lg2:insert(menuRect22)

local sv
local sv2

sv = widget.newScrollView{
    top = properties.center.y - lg.contentHeight * 0.5 - 100,
    left = properties.center.x - lg.contentWidth * 0.5,
    width = lg.contentWidth +20,
    height = lg.contentHeight -80 ,
    scrollHeight = lg.contentHeight,
    hideBackground = true,
    isBounceEnabled = false,
    hideScrollBar = true,
    horizontalScrollDisabled = true,
    isLocked = false,
}

sv2 = widget.newScrollView{
    top = properties.center.y - lg.contentHeight * 0.5 + 100,
    left = properties.center.x - lg.contentWidth * 0.5 ,
    width = lg.contentWidth +20,
    height = lg.contentHeight -80 ,
    scrollHeight = lg.contentHeight,
    hideBackground = true,
    isBounceEnabled = false,
    hideScrollBar = false,
    horizontalScrollDisabled = true,
    isLocked = false,
}

sv:insert(lg)
sv2:insert(lg2)

sceneGroup:insert(sv)
sceneGroup:insert(sv2)

【讨论】:

  • 我真的很怀疑这一点。您如何展示创建两个滚动视图并将它们添加到情节提要的代码?
【解决方案2】:

问题是 corona 的文档是错误的,设置滚动条可见性的属性不是hideScrollBar = false 它是autoHideScrollBar = false

让我困了好几天!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-25
    • 1970-01-01
    • 2013-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-19
    相关资源
    最近更新 更多