[英]Appodeal Banner Ad Covers Screen Android/LibGDX
我正在嘗試將 Appodeal 橫幅添加到 LibGDX 應用程序中,但橫幅廣告覆蓋了屏幕而不是放置在其上方。 我找不到在 LibGDX 中使用 Appodeal 的任何教程,所以我正在從本教程中使用 LibGDX 中的 Admob。 https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx
我無法弄清楚如何以 View 的形式獲取 Appodeal 橫幅廣告,可以使用 addView() 方法將其添加到 RelativeLayout。 我嘗試了幾種方法來做到這一點,它們被標記為“ATTEMPT #1”和“ATTEMPT #2”,但在這兩種嘗試中,橫幅廣告都沒有顯示。 “Appodeal.show(this, BANNER);”這一行將橫幅放在屏幕頂部,因此被注釋掉。 任何幫助得到這個數字將不勝感激。 謝謝。
這是我的 AndroidLauncher.java 文件,我在其中創建並顯示橫幅廣告。
public class AndroidLauncher extends AndroidApplication {
private final int BANNER = 4;
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
// LAYOUT: combines LibGDX View and Ad View
RelativeLayout relativeLayout = new RelativeLayout(this);
// Ad View
Appodeal.initialize(this, "fee50c333ff3825fd6ad6d38cff78154de3025546d47a84f", BANNER);
Appodeal.setTesting(true);
// Appodeal.show(this, BANNER);
// ATTEMPT #1
BannerView bannerView = Appodeal.getBannerView(this);
// ATTEMPT #2
// BannerView bannerView = new BannerView(this, null);
// Appodeal.setBannerViewId(bannerView.getId());
// LibGDX View
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
View libgdxView = initializeForView(new AppodealGDXDemo(), config);
// add to view
relativeLayout.addView(bannerView);
relativeLayout.addView(libgdxView);
// set layout
setContentView(relativeLayout);
}
}
我終於在 Appodeal 網站上找到了幫助我的信息。 https://wiki.appodeal.com/en/android/2-5-8-android-sdk-integration-guide/ad-types看來他們已經對他們的網站進行了很多更改,因為他們的網站上的文檔鏈接我從谷歌找到的網站重定向到主頁。
我現在開始工作了,這是更新的代碼。
public class AndroidLauncher extends AndroidApplication {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
// LAYOUT: combines LibGDX View and Ad View
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
// Ad View
Appodeal.initialize(this, "fee50c333ff3825fd6ad6d38cff78154de3025546d47a84f", Appodeal.BANNER_VIEW);
Appodeal.setTesting(true);
BannerView bannerView = Appodeal.getBannerView(this);
Appodeal.show(this, Appodeal.BANNER_VIEW);
// LibGDX View
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
View libgdxView = initializeForView(new AppodealGDXDemo(), config);
// add to layout
layout.addView(bannerView);
layout.addView(libgdxView);
// set layout
setContentView(layout);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.