智能横幅广告
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
作为一种广告单元,智能横幅可在任何屏幕尺寸、任何屏幕方向的各种设备上展示与屏幕等宽的横幅广告。智能横幅广告可以检测设备处于当前屏幕方向时的宽度,并据此创建与之等宽的广告视图。
智能横幅可实现三种广告高度:
广告高度 |
屏幕高度 |
32 dp |
≤ 400 dp |
50 dp |
> 400 dp 且 ≤ 720 dp |
90 dp |
> 720 dp |
通常情况下,在手机上,当屏幕为纵向时,智能横幅广告高度为 50dp;当屏幕为横向时,广告高度为 32dp。在平板电脑上,不论屏幕方向为纵向还是横向,横幅高度通常均为 90dp。
当图片广告不足以占据所分配的整个空间时,系统会居中放置图片,然后填充两侧剩余的空间。

如需在 XML 中使用智能横幅广告,请为广告尺寸指定常量 SMART_BANNER
,并将 AdView
的宽度设置为 match_parent
。例如:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
如需以编程方式制作智能横幅广告,请将 AdSize.SMART_BANNER
用作广告尺寸:
Java
AdView adView = new AdView(this);
adView.setAdSize(AdSize.SMART_BANNER);
Kotlin
val adView = AdView(this)
adView.adSize = AdSize.SMART_BANNER
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-04-18。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-04-18。"],[[["Smart Banners are responsive ad units that adjust their size to fit the width of the device screen across various devices and orientations."],["They automatically determine the appropriate ad height (32 dp, 50 dp, or 90 dp) based on the screen height of the device."],["It is recommended to use the newer adaptive banners for better performance and user experience."],["Smart Banners can be easily implemented in XML by setting the `adSize` to `SMART_BANNER` and the `AdView` width to `match_parent`, or programmatically by using `AdSize.SMART_BANNER`."]]],[]]