I have integrated Admob which is serving DFP ads. Here is the XML code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/headerAdLayout"
android:paddingLeft="0dp"
android:paddingRight="0dp">
<com.google.android.gms.ads.doubleclick.PublisherAdView
android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
ads:adUnitId="/4359979/Top"
ads:adSize="BANNER"
>
</com.google.android.gms.ads.doubleclick.PublisherAdView>
</LinearLayout>
I then explicitly set the ad sizes prior to loading the ads to try to ensure that there is enough space. I have additionally ensured that there is no padding both to the left and the right
PublisherAdView mAdView = (PublisherAdView) header.findViewById(R.id.adView);
mAdView.setMinimumWidth(720);
mAdView.setMinimumHeight(404);
mAdView.setAdSizes(new AdSize(720, 404));
PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();
mAdView.loadAd(adRequest);
However I still get this message in Logcat:
Not enough space to show ad. Needs 720x404 dp, but only has 533x404 dp.
My screen width is being reported as 800 using the following code. (am running in landscape mode on a Samsung S4 mini device)
WindowManager wm = (WindowManager) activity.getSystemService(activity.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
int width = display.getWidth();
Where am I getting it wrong?