[solved] Ui::ScrollView size issues

I am adding a ScrollView to a Layer and it seems that even though I am setting the Size to something small, it is taking up the whole screen…here is what I am doing:

cocos2d::ui::ScrollView* scrollView = cocos2d::ui::ScrollView::create();
scrollView->setBounceEnabled(true);
scrollView->setDirection(cocos2d::ui::ScrollView::Direction::HORIZONTAL);
scrollView->setContentSize(cocos2d::Size(100, 100)); // of the layer
scrollView->setInnerContainerSize(scrollView->getContentSize());

addChild(scrollView, 1);
scrollView->setPosition(cocos2d::Vec2(0,0));

but it is looking like this:

but when I comment out the addChild() everything goes back to normal…

Are you tried force enabling/disabling Clipping to test? You may want to try increasing the width of the inner container to test. It does seem strange based on the code posted.

Do you mean change to scissor clipping?

If I increase the inner container size the green area just gets larger. Everything else is the same.

No, but you could try that, somehow it’s not clipping correctly. Have you changed anything related to clipping? Like the stencil bits, etc. Have you run the cpp-tests ScrollView Horizontal test on your device to confirm that’s working correctly?

UIScrollViewTest.cpp
Node: UI -> GUI ScrollView Editor Test

You could also try replace ScrollView with ListView to test if it’s scrollview specific or not.

I have changed nothing and yes I used cpp-tests to look at how to implement it. It seems to work

So I was missing:

//if you want a different context,just modify the value of glContextAttrs
//it will takes effect on all platforms
void AppDelegate::initGLContextAttrs()
{
    //set OpenGL context attributions,now can only set six attributions:
    //red,green,blue,alpha,depth,stencil
    GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
    
    cocos2d::GLView::setGLContextAttrs(glContextAttrs);
}

in my AppDelegate.cpp.

it is related to change the default settings of color framebuffer and depth framebuffer, how many bits are used for RGB, alpha, depth and stencil
for using Clipping feature, we must enable stencil buffer
the initGLContextAttrs is a cross platform way to specify these parameters for all the supported platforms