Hi,
I think I have shared the source several times, so not sure which version are you using, but this is the addOnGlobalLayoutListener of adView in Main.java:
adView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if ((adView.getTag() != null) && (adView.getTag() instanceof Boolean)) {
int lAdHeight = adView.getHeight();
int lAdWidth = adView.getWidth();
int screen_height = Resources.getSystem().getDisplayMetrics().heightPixels;
Toast.makeText(myContext, "lAdHeight = " + lAdHeight + "\n" +
"screen_height = " + screen_height, Toast.LENGTH_SHORT).show();
Log.d(TAG, "Ads: Google banner: Width x Height=" + lAdWidth + " x " + lAdHeight);
Log.d(TAG, "Ads: Screen_height=" + screen_height);
if ((0 != lAdHeight) && (0 == viewPager.getPaddingBottom())
&& (lAdHeight < (screen_height * 0.16))) {
viewPager.setPadding(0, 0, 0, lAdHeight);
}
}
}
});
Note, that this
(lAdHeight < (screen_height * 0.16)) condition is my current workaround (and I have the Toast commented out in production version), so screen will not be messed up, but the Toast will show that first the
lAdHeightis is abnormally high and then it is normalized.
Br,
Gabor