How do I change the screen resolution in real time on Android?



cocos2d-x to make the game during the process of porting the android there’s a problem.

960 * 640 resolution, according to my design, I did.

Android main.cpp file in the folder jni

CCEGLView * view = & CCEGLView :: sharedOpenGLView ();
view~~> setFrameSize ;
/ / view~~> setDesignResolutionSize (960,640);

Above, from the same source gave uncomment the third source.

When did comment its Android devices coming out of the resolution to fit,
When did uncomment on the screen grows smaller, empty space on both sides has occurred.

CCEGLView after starting as a way to change the screen size please let me know.

My intent of the game, the user can adjust the size of the screen are trying to make.
Please let me know the source code necessary to me.


If your design resolution size is 960*640(w/h —>3/2), and your device screen ratio is also 3/2, your game will not contain black border. Otherwise, you can not avoid black border on the side of screen. Because we are using the same ratio for width and height to scale.


um … I will try to porting to the nexus one. Its resolution is 800 * 480.