菜鸟教程小白 发表于 2022-12-12 23:33:02

android - Corona newScrollView hideScrollBar 仍然显示滚动条


                                            <p><p>我这样声明 ScrollView :</p>

<pre><code>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,
}
</code></pre>

<p>不幸的是,无论我在“hideScrollBar”中设置什么,滚动条仍然可见。
有没有可能隐藏滚动条?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我发现了一个问题!
当您声明两个或多个 ScrollView 时会发生这种情况。它们中的最后一个覆盖了“hideScrollBar”设置。所以没有选择有两个 ScrollView ,一个有滚动条,一个没有滚动条。</p>

<p>这是证明问题的代码</p>

<p>properties.lua</p>

<pre><code>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
</code></pre>

<p>main.lua</p>

<pre><code>display.setStatusBar( display.HiddenStatusBar )


local properties = require(&#34;properties&#34;)
local widget = require(&#34;widget&#34;)

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)
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于android - Corona newScrollView hideScrollBar 仍然显示滚动条,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/24492072/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/24492072/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: android - Corona newScrollView hideScrollBar 仍然显示滚动条