Unity android插件 - 广告不会出现在屏幕的底部

时间:2014-02-17 23:31:06

标签: java android unity3d

我正在尝试制作一个插件,因此我可以在Unity中使用亚马逊移动广告,但出于某种原因,我无法让它坚持到屏幕的底部。它总是出现在屏幕的顶部。该应用程序处于横向模式。

这是插件代码。

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 个答案:

答案 0 :(得分: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));