
原文:Upgrade your banner ads with new adaptive anchor banners
现在的移动设备类型各种各样,屏幕尺寸更是层出不穷(UI布局适配问题已经不再只是Android同学头痛的事情了)。横幅广告为了更充分的适配不同宽高比的设备,Google Admob SDK创建了一个新的横幅广告类型:adaptive anchor banners。
自适应横幅广告的优势
Adaptive anchor banners are designed to be a drop-in replacement for the industry standard 320x50 banner size and the smart banner format.
自适应横幅广告旨在暂时取代符合行业标准的 320x50 横幅广告尺寸及智能横幅广告格式。
标准的 320x50 横幅广告,在不同分辨率的设备上,展示效果不可控,不是太小就是太大。而智能横幅广告格式仅支持固定高度,因此通常返回的广告素材在高分辨率设备上看起来太小。
Adaptive anchor banners return creatives with the best height and aspect ratio for each device, with hard limits to prevent the wrong sizes from being served.
自适应横幅广告是一种更好的选择,原因如下:
这种广告采用提供的宽度(而非全屏宽度),这样您就可以将安全区域考虑在内。
它会为特定设备选择最优高度,而非针对不同尺寸的设备均使用固定高度,从而降低了设备屏幕尺寸造成的影响。
Standard banner vs. smart banner vs. AdMob’s adaptive anchor banner
快速入门
Adaptive anchor banners are currently only available for anchored placements—banners locked to the top or bottom of the screen.
这种横幅广告的尺寸通常用于锚定横幅广告(通常被锁定在屏幕的顶部或底部)。
要植入简单的自适应锚定横幅广告,请按照以下步骤操作:
- 创建一个
GADBannerView对象并设置广告单元 ID。 - 获取自适应横幅广告尺寸。 您获取的尺寸将用于请求自适应横幅广告。要获取自适应广告尺寸,请务必执行以下操作:
- 获取所用设备的宽度,或者自行设置宽度(如果您不想使用屏幕的全宽)。
- 针对广告尺寸类使用相应的静态方法(例如
GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(CGFloat width)),以获取所选屏幕方向的自适应GADAdSize对象。 - 针对横幅广告视图设置广告尺寸,具体做法是,在
GADBannerView上设置adSize属性。
- 在预先准备的广告视图中使用
loadRequest方法创建广告请求对象并加载横幅广告,其处理方式与常规横幅广告请求一样。