2013-07-21 73 views
0

我有以下代碼在我的遊戲上顯示來自Admob的廣告。如何在Andengine中從Admob旋轉Adview?

問題出現在這裏。我的遊戲處於橫向模式,但我希望廣告能夠進入Potrait模式。

現狀http://postimg.org/image/z4dc271x9/

最終輸出所需http://postimg.org/image/83d7afe9h/

我應該在我的代碼改變?

this.mRenderSurfaceView = new RenderSurfaceView(this); 

    this.mRenderSurfaceView.setRenderer(this.mEngine,this); 
    final android.widget.FrameLayout.LayoutParams surfaceViewLayoutParams = new FrameLayout.LayoutParams(super.createSurfaceViewLayoutParams()); 

    //Creating the banner view. 
    AdView adView = new AdView(this, AdSize.BANNER, "MY_ID_HERE"); 
    adView.loadAd(new AdRequest()); 
    final FrameLayout.LayoutParams adViewLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER | Gravity.CENTER_HORIZONTAL); 


    final FrameLayout frameLayout = new FrameLayout(this); 

    final FrameLayout.LayoutParams frameLayoutLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.FILL_PARENT); 


    frameLayout.addView(this.mRenderSurfaceView,surfaceViewLayoutParams); 
    frameLayout.addView(adView,adViewLayoutParams); 

    this.setContentView(frameLayout, frameLayoutLayoutParams); 

謝謝!

回答

0

添加兩行創建的AdView後...

//創建橫幅畫面。

AdView adView = new AdView(this, AdSize.BANNER, "MY_ID_HERE"); 
    adView.setRotation(-90.0f); 
    adView.setX(-600.0f); // Adjust the value as per your requirement. 

然後,在下面的行中刪除 「Gravity.CENTER_HORIZONTAL」:

final FrameLayout.LayoutParams adViewLayoutParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER | Gravity.CENTER_HORIZONTAL);