Problems with UIScrollView: Green Background and No Clipping

I have reproduced your problem. Thanks for reporting.

_scrollView->setClippingType(Layout::ClippingType::SCISSOR);

would solve your problem.

Thanks a lot @owen ,it works very well.

My dear @owen, iā€™m sorry but i have another clipping problem .

in my interactive book app, i give the ability to the user to hide/show the scrollView , so i used this code:

 void MainLyer::callBack(cocos2d::Ref *sender) {
 
 if (_slideLayer->getPosition()==Vec2::ZERO) {
        //hide the _layerColor
        _layerColor->runAction(  Sequence::create(EaseBackOut::create(MoveTo::create(0.5f, Vec2(0, -_layerColor->getContentSize().height))),
                                                  NULL ));
        
    }else {
        _layerColor->runAction(  Sequence::create(EaseBackIn::create(MoveTo::create(0.5f, Vec2(0,0))),
                                                  NULL)
                               );
    }
}

The problem is : when i hide the _layerColor , the _scrollView still showing !
Please help me.

@yagoub
If you want to hide scrollView, I think you should also call

scrollView->setVisible(false);

but in my case, i made animation( MoveTo) to take the scrollView off the screen, and this problem exists only if i use this _scrollView->setClippingType(Layout::ClippingType::SCISSOR);

@yagoub

If you want to move the scrollView, you might need to change the clipping type to STENCIL again.

Thanks @owen, it works fine, but is there any other solution ?

Currently, Iā€™m sorry, noā€¦

Just wanted to share that after moving from 3.2 to 3.3 all my ListViews started to have green backgrounds and incorrect clipping. It worked absolutely fine in 3.2.

Problem went away when I added Owenā€™s code
void AppDelegate::initGLContextAttrs()
{
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setGLContextAttrs(glContextAttrs);
}

I use 3.10 and scrollerview still green and no clipping on Android device. Please help me :disappointed_relieved: !

@C7an I ran into this problem using 3.11 setting the clipping type to SCISSOR seems to make it work. I read in another old post that some devices donā€™t support scissor clipping. Is that still a concern? It only occurrs on an android emulators ran on windows. Other computers (linux) and real android devices work as expected. Bluestacks on the same computer even works.

This has to do with the android emulator. See this topic and star it if you want google to fix it: https://code.google.com/p/android/issues/detail?id=207017

Has anyone seen this recently on anything other than the android emulator that wasnā€™t fixed by the posts towards the top of this topic or this topic: [solved] Ui::ScrollView size issues ?

Iā€™ve just bumped into this testing pre-release on Android Simulator on OSX and it still happens, so itā€™s not a Windows-only issue. I definitely already have the fix above too.

Iā€™m about to go into beta so will see if this occurs on any physical devices too and report backā€¦

Iā€™ve already submitted a fix to Cocos, but for some reason they havenā€™t applied it. Itā€™s easy to fix. Hereā€™s my quote from the GitHub Issue:

Iā€™ve managed to fix this by changing the following on line 398 of Cocos2dxActivity.java

from:

this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);

to:

this.mGLSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 8);

The stencil was disabled on the emulator for some reason (Iā€™m not sure why). Setting the stencil buffer to 8-bit fixed the Scrollview appearing in green.

1 Like

Oh, great find. Itā€™s a relief to see this is specifically due to the simulator configuration, takes a lot off my mind.

I have these errors (green/black backgrounds) with android devices, one year ago. I use them on current projects without problem. Without editing java files.

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    GLContextAttrs glContextAttrs = {8, 8, 8, 8, 16, 8};
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
    GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
#endif

Just saying, this issue is still present on cocos2d-x 3.17, but this fix works.

1 Like