using space when ad is not loaded android(未加载广告时使用空间android)
问题描述
我正在尝试在我的应用程序中添加 admob 广告,但是当我没有连接到互联网时,空间太小了......
I am trying to add admob ads in my application but when I am not connected to internet than too empty space is there...
我希望添加在加载后出现,直到广告空间应该被其余元素使用
I want add to appear after loading until then ad space should be utilized by the rest elements
怎么办???
我的活动文件如下 -
My Activity file is given below -
MainActivity.java`
推荐答案
保持可见性
即您最初将 Adview
添加到 View.GONE
的布局,因此它不会占用任何空间.
i.e. the layout to which you are adding your Adview
to View.GONE
initially so it will occup no space.
现在添加一个 AdListener
到 AdView
并在 onAdLoaded
中制作上述布局 View.VISIBLE
AdListener
的方法.这样,在加载 Ad
之前,布局将永远不可见.
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.
例如.
注意:您必须使用最新的 google-play-services-lib
而不是 AdMobsSDK
NOTE: You will have to use the latest google-play-services-lib
not AdMobsSDK
这篇关于未加载广告时使用空间android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!