java如何防止AdMob广告被放置在活动的底部?
我正在我的MainActivity
中的RecyclerView
中随机显示广告,使用以下代码:
public static int count = 0;
public static int random = 0;
if (count >= random) {
random = rand.nextInt(4); // Reset the counter to random integer
count = 0;
adView.setVisibility(View.VISIBLE);
AdRequest request = new AdRequest.Builder()
.addTestDevice("XXXXXXXXXXX")
.addTestDevice("XXXXXXXXXXX")
.addTestDevice("XXXXXXXXXXX")
.build();
adView.loadAd(request);
} else {
count++;
}
下面是xml
代码:
<com.google.安卓.gms.ads.NativeExpressAdView
安卓:id="@+id/adView"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:layout_gravity="center"
ads:adUnitId="ca-app-***-****/*****"
ads:adSize="320x80">
</com.google.安卓.gms.ads.NativeExpressAdView>
我在这项活动中有一个FAB,正如谷歌AdMob政策中明确指出的那样
an ad should not be placed too near any action button or interactive UI component of the app to prevent accidential clicks which can lead to ban of the account.
因此,在我的例子中,FAB
有时与ad重叠
我想知道的是如何防止广告被放在活动的底部
有没有办法从xml
文件或以编程方式执行此操作?请让我知道
共 (0) 个答案