錨定自動調整橫幅廣告
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
自動調整橫幅廣告是新一代的回應式廣告,可針對每部裝置調整廣告大小,藉此獲得最佳成效。原本智慧型橫幅廣告僅支援固定高度,改良後的自動調整橫幅廣告則可讓您指定廣告寬度,從而決定理想的廣告大小。
為了選擇最適合的廣告大小,自動調整式橫幅廣告採用固定的顯示比例,而非固定高度。進而使不同裝置和螢幕大小上顯示的橫幅廣告版面比例更加一致,有助提升廣告成效。
使用自動調整橫幅廣告時,請注意,這類廣告一律會針對特定裝置和寬度傳回固定大小,在特定裝置上測試版面配置後,您就能確定廣告大小不會變更。不過,橫幅廣告素材的大小可能會因裝置而異。因此,建議您確保版面配置可容納廣告高度的差異。在極少數情況下,系統可能無法填滿完整自適應大小,而是將標準尺寸的廣告素材置中顯示在這個廣告空間中。
自動調整橫幅廣告的使用時機
在設計上,自動調整橫幅廣告旨在直接取代業界標準的 320x50 橫幅廣告大小,以及智慧型橫幅廣告格式。
這些橫幅大小通常會做為錨定橫幅使用,且通常會固定在畫面頂端或底部。對於這類錨定橫幅,使用自動調整橫幅時的長寬比會與標準 320x50 廣告類似,如以下螢幕截圖所示:

320x50 橫幅廣告
|

智慧型橫幅廣告
|

自動調整橫幅廣告
|
自動調整橫幅廣告可更充分利用可用螢幕大小。此外,相較於智慧型橫幅廣告,自動調整橫幅廣告是更好的選擇,原因如下:
實作注意事項
在應用程式中導入自動調整橫幅廣告時,請注意下列事項:
您必須知道廣告的放置檢視區塊寬度,並將裝置寬度和任何適用的安全區域納入考量。
如果放送的廣告尺寸較小,無法填滿廣告版位,請務必將廣告檢視畫面背景設為不透明,以免違反 AdMob 政策。
請確認您使用的是最新版 Google Mobile Ads C++ SDK。如要使用中介服務,請使用各中介服務轉接程式的最新版本。
自動調整橫幅廣告的設計宗旨,是盡可能使用可用寬度,以達到最佳成效。在大多數情況下,這會是所用裝置螢幕的完整寬度。請務必將適用的安全區域納入考量。
Google Mobile Ads C++ SDK 會在 firebase::gma::AdSize
中,針對指定寬度傳回最佳化的廣告高度。
取得自動調整橫幅廣告尺寸的方法有三種:一種適用於橫向模式,一種適用於直向模式,另一種則適用於執行時的目前方向。
針對特定裝置和寬度,系統一律會傳回固定的大小,因此在特定裝置上測試版面配置後,您就能確定廣告大小不會改變。
錨定式橫幅的高度不會超過裝置高度的 15%,也不會小於 50 點。
快速入門
導入簡易自動調整錨定橫幅廣告的步驟如下:
取得自動調整橫幅廣告尺寸。您取得的尺寸會用於請求自動調整橫幅廣告。如要取得自動調整廣告尺寸,請務必完成下列操作:
取得所用裝置的寬度,或者,如果您不想使用畫面的完整寬度,請自行設定需要的寬度。
針對 AdSize
類別使用適當的靜態方法 (例如 GetCurrentOrientationAnchoredAdaptiveBannerAdSize(uint32_t width)
),取得所選螢幕方向的自動調整 AdSize
物件。
在 AdView
上叫用 Initialize()
的 AdView
,並使用您建立的自動調整式 AdSize
。
完整範例如下。
建立 AdRequest
物件,然後在您準備的廣告檢視畫面上使用 loadAd()
方法載入橫幅廣告,做法與處理一般橫幅廣告請求相同。
程式碼範例
以下範例會載入自動調整式橫幅的 AdView
:
// Determine view width in pixels based on your app's current width on the
// device's screen. This process will vary depending on which windowing toolkit
// you're using.
firebase::gma::AdSize adaptive_ad_size =
AdSize::GetCurrentOrientationAnchoredAdaptiveBannerAdSize(view_width);
// my_ad_parent is a reference to an iOS UIView or an Android Activity.
// This is the parent UIView or Activity of the banner view.
firebase::gma::AdParent ad_parent =
static_cast<firebase::gma::AdParent>(my_ad_parent);
firebase::Future<void> result =
ad_view->Initialize(ad_parent, kBannerAdUnit, adaptive_ad_size);
在這裡,函式 GetCurrentOrientationAnchoredAdaptiveBannerAdSize(uint32_t width)
用於取得目前介面方向的錨定位置中,橫幅的大小。如要在特定螢幕方向預先載入錨定橫幅,請使用 GetPortraitAnchoredAdaptiveBannerAdSize(uint32_t width)
和 GetLandscapeAnchoredAdaptiveBannerAdSize(uint32_t width)
中的相關函式。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-02 (世界標準時間)。
[null,null,["上次更新時間:2025-09-02 (世界標準時間)。"],[[["\u003cp\u003eAdaptive banners optimize ad size for each device, improving performance by using fixed aspect ratios for a consistent screen presence.\u003c/p\u003e\n"],["\u003cp\u003eThey are drop-in replacements for standard 320x50 banners and smart banners, best used as anchored banners (top or bottom of the screen).\u003c/p\u003e\n"],["\u003cp\u003eAdaptive banners offer advantages over smart banners by utilizing provided width for safe areas and adjusting height for optimal display on various devices.\u003c/p\u003e\n"],["\u003cp\u003eImplementation requires knowing the ad view's width (considering device width and safe areas), using an opaque background, and the latest Google Mobile Ads C++ SDK.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can obtain the adaptive banner size using \u003ccode\u003eAdSize\u003c/code\u003e class methods, considering device width and orientation, to initialize and load the ad view.\u003c/p\u003e\n"]]],["Adaptive banners optimize ad size per device using fixed aspect ratios instead of fixed heights, improving performance and screen usage compared to smart banners. Key actions include determining the ad view width, accounting for safe areas, and using `AdSize` methods (e.g., `GetCurrentOrientationAnchoredAdaptiveBannerAdSize`) to get the optimal ad size for a specific orientation. Developers should ensure opaque ad view backgrounds and use the latest SDK. The returned ad size remains consistent on a given device but may differ across devices.\n"],null,["Adaptive banners are the next generation of responsive ads, maximizing\nperformance by optimizing ad size for each device. Improving on smart banners,\nwhich only supported fixed heights, adaptive banners let you specify the\nad-width and use this to determine the optimal ad size.\n\nTo pick the best ad size, adaptive banners use fixed aspect ratios instead of\nfixed heights. This results in banner ads that occupy a more consistent portion\nof the screen across devices and provide opportunities for improved performance.\n\nWhen working with adaptive banners, note that they will always return a\nconstant size for a given device and width. Once you've tested your layout on a\ngiven device, you can be sure that the ad size will not change. However, the\nsize of the banner creative may change across different devices. Consequently,\nit is recommended to ensure your layout can accommodate variances in ad height.\nIn rare cases, the full adaptive size may not be filled and a standard size\ncreative will be centered in this slot instead.\n\nWhen to use adaptive banners\n\nAdaptive banners are designed to be a drop-in replacement for the industry\nstandard 320x50 banner size, as well as the smart banner format they supersede.\n\nThese banner sizes are commonly used as anchored banners, which are usually\nlocked to the top or bottom of the screen. For such anchored banners, the aspect\nratio when using adaptive banners will be similar to that of a standard 320x50\nad, as can be seen in these screenshots:\n\n|---------------|--------------|-----------------|\n| 320x50 banner | Smart banner | Adaptive banner |\n\nAn adaptive banner makes better use of the available screen size. Additionally,\ncompared to a smart banner, an adaptive banner is a better choice because:\n\n- It uses a provided width rather than full screen width, enabling you to\n account for safe areas.\n\n- It selects an optimal height for the specific device, rather than having a\n constant height across different sized devices, mitigating the effects of\n device fragmentation.\n\nImplementation notes\n\nWhen implementing adaptive banners in your app, keep the following points in\nmind:\n\n- You must know the width of the view that the ad will be placed in, *and this\n should take into account the device width and any safe areas that are\n applicable*.\n\n- Ensure that your ad view background is opaque to be compliant with AdMob\n policies when smaller ad sizes serve that do not fill the ad slot.\n\n- Ensure you are using the latest version of the Google Mobile Ads C++ SDK. For\n mediation, use the latest version of each mediation adapter.\n\n- The adaptive banner sizes are designed to work best when using the full\n available width. In most cases, this will be the full width of the screen of\n the device in use. Be sure to take into account applicable safe areas.\n\n- The Google Mobile Ads C++ SDK returns an optimized ad height for the given\n width in a `firebase::gma::AdSize`.\n\n- There are three methods to get an ad size for adaptive banners---one for\n landscape, one for portrait, and one for the current orientation at the time\n of execution.\n\n- The size returned for a given width on a given device will always be the same,\n hence once you've tested your layout on a given device, you can be sure that\n the ad size will not change.\n\n- Anchored banner height is never larger than 15% of the device's height and\n never smaller than 50 points.\n\nQuick start\n\nFollow the steps below to implement a simple adaptive anchor banner.\n\n1. Get an adaptive banner ad size. The size you get will be used to request\n your adaptive banner. To get the adaptive ad size, make sure that you:\n\n 1. Get the width of the device in use, or set your own width if you don't\n want to use the full width of the screen.\n\n 2. Use the appropriate static methods on the `AdSize` class, such as\n `GetCurrentOrientationAnchoredAdaptiveBannerAdSize(uint32_t width)` to\n get an adaptive `AdSize` object for the chosen orientation.\n\n 3. Invoke `Initialize()` on the `AdView` with the adaptive `AdSize` you've\n created.\n\n A full example is included below.\n2. Create an `AdRequest` object and load your banner using the `loadAd()`\n method on your prepared ad view, just like you would with a normal banner\n request.\n\nSample code\n\nHere's an example of an `AdView` that will load an adaptive banner: \n\n // Determine view width in pixels based on your app's current width on the\n // device's screen. This process will vary depending on which windowing toolkit\n // you're using.\n\n firebase::gma::AdSize adaptive_ad_size =\n AdSize::GetCurrentOrientationAnchoredAdaptiveBannerAdSize(view_width);\n\n // my_ad_parent is a reference to an iOS UIView or an Android Activity.\n // This is the parent UIView or Activity of the banner view.\n firebase::gma::AdParent ad_parent =\n static_cast\u003cfirebase::gma::AdParent\u003e(my_ad_parent);\n firebase::Future\u003cvoid\u003e result =\n ad_view-\u003eInitialize(ad_parent, kBannerAdUnit, adaptive_ad_size);\n\nHere, the function\n`GetCurrentOrientationAnchoredAdaptiveBannerAdSize(uint32_t width)` is used to\nget the size for a banner in an anchored position for the current interface\norientation. For pre-loading an anchored banner in a given orientation, use the\nrelevant function from `GetPortraitAnchoredAdaptiveBannerAdSize(uint32_t width)`\nand `GetLandscapeAnchoredAdaptiveBannerAdSize(uint32_t width)`."]]