如何在Andengine中使用比率解析策略时更改onSetContentView中的位置

时间:2013-07-27 07:26:48

标签: android admob andengine

我正在开发(学习构建:))与发动机GLES1的游戏。我重写了setContentView以放置我的admob广告。 除了解决方案政策外,每件事情都可以。我不能按照我想要的方式放置广告。由于我的游戏处于横向模式,我希望广告位于右侧,广告将处于纵向模式。所以我尝试使用相对布局而不是Frame。这是我的代码

final RelativeLayout relativeLayout = new RelativeLayout(this);
        final FrameLayout.LayoutParams relativeLayoutLayoutParams = new FrameLayout.LayoutParams(
                RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.FILL_PARENT);

        this.mRenderSurfaceView = new RenderSurfaceView(this);
        mRenderSurfaceView.setRenderer(mEngine);

        final FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.FILL_PARENT,
                FrameLayout.LayoutParams.FILL_PARENT,Gravity.CENTER);

        final android.widget.RelativeLayout.LayoutParams surfaceViewLayoutParams = new RelativeLayout.LayoutParams(layoutParams);
        surfaceViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        relativeLayout.addView(this.mRenderSurfaceView, surfaceViewLayoutParams);


        FrameLayout frameLayout = new FrameLayout(this);        
        adView = new AdView(this, AdSize.BANNER, "a151e9960c73925");
        adView.refreshDrawableState();
        adView.setVisibility(AdView.VISIBLE);
        frameLayout.addView(adView);
        relativeLayout.addView(frameLayout);
        this.setContentView(relativeLayout, relativeLayoutLayoutParams);

但它不再显示广告。请帮忙。提前谢谢。

0 个答案:

没有答案