Ui::PageView bug with v3 rc1 : Green background on Android

I’m porting my v3 beta02 code to v3 rc1.
I noticed that ui::PageView class has an odd green background when testing on my Android device.

It can be reproduced with changing the init() method in HelloWorldScehe.cpp with this :

// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    if ( !Layer::init() ) return false;

    
    Size visibleSize = Director::getInstance()->getVisibleSize();
    
    // Create the page view
    PageView* pageView = PageView::create();
    pageView->setTouchEnabled(true);
    pageView->setSize(visibleSize);
    
    for (int i = 0; i < 3; ++i)
    {
        Layout* layout = Layout::create();
        layout->setSize(visibleSize);

        ImageView *imgV = ImageView::create();
        imgV->loadTexture("HelloWorld.png");
        imgV->setPosition(Point(layout->getSize().width / 2.0f,
                                layout->getSize().height / 2.0f));
        layout->addChild(imgV);
        
        Text *textV = Text::create();
        textV->setText(String::createWithFormat("Page %d", i)->getCString());
        textV->setPosition(Point(layout->getSize().width/ 2.0f,
                                 imgV->getPositionY() - 200));
        textV->setFontSize(40);
        layout->addChild(textV);
        
        pageView->addPage(layout);
    }
    
    addChild(pageView);
    
    
    return true;
}


PageView-greenbackground.jpg (19.2 KB)

@barisatamer
this issue is not a bug, but due to some configuration problems.

You could add the following code into your NativeActivity.java file to get ride of this problem.

import org.cocos2dx.lib.Cocos2dxActivity;
import org.cocos2dx.lib.Cocos2dxGLSurfaceView;

public class AppActivity extends Cocos2dxActivity {
	public Cocos2dxGLSurfaceView onCreateView() {
        Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
        glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
        return glSurfaceView;
    }
}

2 Likes

@owen
Thanks for the code, it fixed the problem.

This config didn’t solve the issue for me, I am using the emulator.

@vns

please try the android device, emulator is slow and buggy.

Thanx owen! Great Help!