I\'ve got a problem. My AdMob has been set up for some time now without any problem, but I noticed something wrong. Ad gets successfully loaded (i see message from ddms), bu
The above solution works. Even a simpler way to keep the banner shown is to set its background.
adMobView.setBackgroundColor(Color.BLACK);
banner.setBackgroundColor(Color.TRANSPARENT);
This seems to fix the issue for me. Also be sure to run the banner creation code from within the UI thread.
activity.runOnUiThread(new Runnable()
{
@Override
public void run()
{
// all your banner creation code is here
banner.setBackgroundColor(Color.TRANSPARENT);
}
});
As nobody has replied with explanation, I'm going to consider this one solved. I just manually reload whole layout onAdLoad event. Anyway, this is just functional solution, it does not explain why it happens with Google Play Services AdMob.
adMobView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
super.onAdLoaded();
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
layout.requestLayout();
}
});
}
});
Also, as mentioned by user3263204, you can try this
adMobView.setBackgroundColor(Color.BLACK);
to solve your problem.
As user3263204 says, you can use setBackgroundColor to make the adview appear. You can make the background transparent, if (as in my case) you have the adview over something else:
adMobView.setBackgroundColor(getResources().getColor(android.R.color.transparent));
You can also requestWindowFeature(Window.FEATURE_NO_TITLE); and set to full screen and the ads shows.