gpt4 book ai didi

android - 在屏幕底部显示 AdMob 横幅

转载 作者:行者123 更新时间:2023-11-29 15:09:43 28 4
gpt4 key购买 nike

我的 AdMob 横幅显示在屏幕顶部而不是底部。

这是我的代码:

adView = new AdView(mSingleton);
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId("ca-app-pub-xxxxxxxxxxxxxxx/xxxxxxx");

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RelativeLayout.LayoutParams.WRAP_CONTENT);

params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
params.addRule(RelativeLayout.CENTER_HORIZONTAL);

AdRequest adRequest = new AdRequest.Builder()
.addTestDevice("XXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
.build();
adView.loadAd(adRequest);
mLayout.addView(adView, params);

感谢任何帮助。谢谢。

最佳答案

用这个替换你的广告代码

<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx">

</com.google.android.gms.ads.AdView>

关于android - 在屏幕底部显示 AdMob 横幅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32952521/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com