Android 固定广告在活动的底部
我有一个LiveWallpaper的PreferenceActivity,并使用这里的解决方案()创建了一个Admob广告。它可以工作,但当用户上下滚动时广告消失,当它进入视图时再次加载。有没有办法让广告始终停留在活动的底部(或顶部)(如在常规活动中)?之前Android 固定广告在活动的底部,android,admob,preferenceactivity,Android,Admob,Preferenceactivity,我有一个LiveWallpaper的PreferenceActivity,并使用这里的解决方案()创建了一个Admob广告。它可以工作,但当用户上下滚动时广告消失,当它进入视图时再次加载。有没有办法让广告始终停留在活动的底部(或顶部)(如在常规活动中)?之前 ((LinearLayout)view).addView(adView); 尝试将layoutParam设置为 adView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PAREN
((LinearLayout)view).addView(adView);
尝试将layoutParam设置为
adView.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT))
或更改布局,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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_alignParentLeft="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id"/>
</RelativeLayout>
请提供XML布局。
mAdView = (AdView) findViewById(R.id.adView);
mAdView.setAdListener(new ToastAdListener(this));
mAdView.loadAd(new AdRequest.Builder().build());