可收合橫幅廣告
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
可收合橫幅廣告一開始會以較大的重疊廣告顯示,並提供按鈕,可將廣告收合為原先要求的橫幅廣告大小。可收合橫幅廣告旨在提升錨定廣告的成效,因為這類廣告的尺寸較小。本指南說明如何為現有的橫幅刊登位置啟用可摺疊的橫幅廣告。

必要條件
實作
請確認橫幅檢視畫面已定義您希望使用者在一般 (收合) 橫幅狀態中看到的大小。在廣告要求中加入額外參數,並將 collapsible
設為鍵,廣告刊登位置設為值。
可收合刊登位置會定義展開區域如何錨定橫幅廣告。
Placement 值
|
行為 |
預定用途 |
top |
展開廣告的頂端會與收合廣告的頂端對齊。 |
廣告位於畫面頂端。 |
bottom |
展開廣告的底部會與收合廣告的底部對齊。 |
廣告會置於畫面底部。 |
如果載入的廣告是可摺疊的橫幅廣告,橫幅廣告會在放入檢視階層後立即顯示可摺疊的疊加層。
void _loadAd() async {
// Replace these test ad units with your own ad units.
final String adUnitId = Platform.isAndroid
? 'ca-app-pub-3940256099942544/2014213617'
: 'ca-app-pub-3940256099942544/8388050270';
// Get the size before loading the ad.
final size = await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
MediaQuery.sizeOf(context).width.truncate());
if (size == null) {
// Unable to get the size.
return;
}
// Create an extra parameter that aligns the bottom of the expanded ad to the
// bottom of the banner ad.
const adRequest = AdRequest(extras: {
"collapsible": "bottom",
});
BannerAd(
adUnitId: adUnitId,
request: adRequest,
size: size,
listener: const BannerAdListener()
).load();
}
廣告重新整理行為
如果應用程式在 Ad Manager 網頁介面中為橫幅廣告設定自動重新整理功能,當系統為橫幅廣告版位要求可收合橫幅廣告時,後續重新整理廣告時就不會再要求可收合橫幅廣告。這是因為在每次重新整理時顯示可收合橫幅廣告,可能會對使用者體驗造成負面影響。
如要在工作階段中的一段時間後,再載入其他可收合橫幅廣告,請在請求中包含可收合橫幅廣告參數,並手動載入廣告。
可收合橫幅廣告僅適用於 Google 廣告需求。透過中介服務放送的廣告會顯示為一般不可收合橫幅廣告。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-02-01 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2025-02-01 (世界標準時間)。"],[[["Collapsible banner ads initially appear larger and can be collapsed to a standard banner size, improving anchored ad performance."],["To enable, include an extra parameter in the ad request with `collapsible` as the key and `top` or `bottom` as the value to specify the expanded ad's alignment."],["Collapsible banners only support Google demand; ads served through mediation will display as regular banners."],["Ads refreshing is automatically configured to avoid repeated collapsible banners, improving user experience."],["For manual control, load an ad with the collapsible parameter to re-enable a collapsible banner ad later in the session."]]],["Collapsible banner ads, which enhance smaller anchored ads, display as a larger overlay initially and then collapse to the defined size. To implement, ensure the banner view is sized for the collapsed state and include an \"extras\" parameter with \"collapsible\" set to \"top\" or \"bottom\" for placement. Subsequent ad refreshes won't be collapsible unless manually requested. Collapsible banners are limited to Google demand, with mediated ads appearing as standard banners.\n"]]