Keep the visibility of
LinearLayout layout = (LinearLayout) findViewById(R.id.LinearLayout1);
i.e. the layout to which you are adding your Adview
to View.GONE
initially so it will occup no space.
Now add an AdListener
to the AdView
and make the above mentioned layout View.VISIBLE
in the onAdLoaded
method of the AdListener
. That way the layout will never be visible until the Ad
is loaded.
For eg.
AdListener googleAdListener = new AdListener()
{
@Override
public void onAdLoaded()
{
super.onAdLoaded();
try
{
(LinearLayout) findViewById(R.id.LinearLayout1).setVisibility(View.VISIBLE);
}
catch (Exception e)
{
Logger.LogException(e);
}
}
};
adView.setAdListener(googleAdListener);
NOTE: You will have to use the latest google-play-services-lib
not AdMobsSDK