2014-02-17 90 views
0

我想製作一個插件,這樣我就可以在Unity中使用亞馬遜移動廣告,但出於某種原因,我無法讓它堅持到底部屏幕。它總是進入屏幕的頂部。該應用程序處於橫向模式。Unity android插件 - 廣告不會放在屏幕的底部

這裏是插件代碼。

public class AmazonAds { 

    public AmazonAds(){ 
    } 

    public static void displayAd(final boolean test){ 
     UnityPlayer.currentActivity.runOnUiThread(new Runnable() { 
      public void run(){ 
       AdRegistration.setAppKey("APPKEY"); 
       AdRegistration.enableTesting(test); 
       AdLayout adView = new AdLayout(UnityPlayer.currentActivity); 
       LinearLayout layout = new LinearLayout(UnityPlayer.currentActivity.getApplicationContext()); 
       layout.setGravity(Gravity.BOTTOM); 
       UnityPlayer.currentActivity.addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
       layout.addView(adView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); 
       adView.loadAd(new AdTargetingOptions()); 
      } 
     }); 
    } 

} 

我應該試試看它是否修復了它?

謝謝!

回答

1

甜蜜我修好了!如果你想知道答案,這是你如何解決它。

AdRegistration.setAppKey("APPKEY"); 
AdRegistration.enableTesting(test); 
adView = new AdLayout(UnityPlayer.currentActivity); 
LinearLayout layout = new LinearLayout(UnityPlayer.currentActivity.getApplicationContext()); 
layout.setGravity(Gravity.BOTTOM); 
UnityPlayer.currentActivity.addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); 
layout.addView(adView, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, 
LayoutParams.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL));