开发者

Adjusting layout when Admob ads get displayed

I am developing a game which uses canvas width and height for proper positioning of things at start. So init code is in SurfaceSizeChanged() method. The game has an admob banner at top whose height is set to "wrap_content", so initially when the game is launched, the ad's height is 0 as there is no ad. After a couple of seconds when admob ad is displayed then the view height gets changed and SurfaceSizeChanged() is called.

    public void SurfaceSizeChanged(int width, int height) {

        this.canvasHeight = height;
        this.canvasWidth = width;

        initGame(null); // we need width height to init
    }

The issue now is that the game is reinitialized as if its just launched. How do I work around this?

Tha开发者_Go百科nks.


For a workaround, I fixed the admob height to 64dip, instead of wrap_content.

So now SurfaceSizeChanged() is not called and there is no issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜