We have been using AdMob on our Android app for more than 4 years. In the last days, we encountered an issue with AdMob, without modifying any code.
As you can see from the picture below:
- PREVIOUSLY, the banner space was reserved, before the banner was loaded
- NOW, the banner space is not reserved before loading, creating a very annoying experience for the user, who sees content shifting down after the banner is loaded
===
Here is a description of our implementation:
we are placing our banner about 20% top of the screen of a fragment, inside a LinearLayout "banner_container"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
....
<LinearLayout android:id="@+id/banner_container"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
....
</LinearLayout>
on Fragment's "onCreateView" we are adding the banner to the container
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
...
adView = new AdView(getActivity());
adView.setAdSize(AdSize.SMART_BANNER);
adView.setAdUnitId(AD_UNIT_ID);
LinearLayout mBannerContainer = rootView.findViewById(R.id.banner_container);
mBannerContainer.setVisibility(View.VISIBLE);
mBannerContainer.addView(adView);
AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .build();
adView.loadAd(adRequest);
...
}
===
How can we revert to the situation where the banner space is already reserved on loading?
gone
for premium users. However, I just tried to changed it tovisible
in the xml layout, but the same happens (consider that it is set tovisibile
in the onCreateView anyway). I think it depends on thelayout_height
which iswrap_content
. For some reason, previously AdMob was setting the height of the banner even before the banner it was loaded, and now not. – Juback