Not enough space to show ad (AdMob)

后端 未结 5 2078
挽巷
挽巷 2020-11-30 13:45

I am trying to show AdMob ads in my activity, but it is always giving error that \"not enough space to show ad\".

My XML file is:



        
5条回答
  •  萌比男神i
    2020-11-30 14:14

    i had the same problem with NativeExpressAdView. If you add padding or margin to your layout, I think, it's not a good idea to fix the ad's size width. I sugger to do in programmatically

    1. First step : get the dp size of screen witdh

      DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics(); //float dpHeight = displayMetrics.heightPixels / displayMetrics.density; dpWidth = displayMetrics.widthPixels / displayMetrics.density;

    2. Second step:

    mAdView.setAdSize(new AdSize((int) dpWidth, 150));

提交回复
热议问题