我正在尝试制作一个插件,因此我可以在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());
}
});
}
}
我应该尝试看看它是否修复了它?
谢谢!
答案 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));