我试图将Appodeal横幅广告插入到LibGDX应用程序中,但横幅广告覆盖了屏幕,而不是放置在屏幕上方。我找不到任何在LibGDX中使用Appodeal的教程,所以我从本教程开始学习在LibGDX中使用Admob。https://github.com/libgdx/libgdx/wiki/Admob-in-libgdx
我不知道如何以视图的形式获得Appodeal横幅广告,该视图可以使用addView()方法添加到RelativeLayout中。我已经尝试了几种方法来做到这一点,它们被标记为“尝试#1”和“尝试#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);
}
}发布于 2019-09-23 23:49:45
我终于在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);
}
}https://stackoverflow.com/questions/58063328
复制相似问题