Quảng cáo biểu ngữ thích ứng cố định
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Biểu ngữ thích ứng là thế hệ tiếp theo của quảng cáo thích ứng, giúp bạn tăng tối đa hiệu suất bằng cách tối ưu hoá kích thước của quảng cáo cho từng thiết bị. Nhờ cải thiện dựa trên biểu ngữ thông minh (vốn chỉ hỗ trợ chiều cao cố định), biểu ngữ thích ứng cho phép bạn chỉ định chiều rộng quảng cáo và sử dụng chiều rộng này để xác định kích thước quảng cáo tối ưu.
Để chọn kích thước quảng cáo phù hợp nhất, biểu ngữ thích ứng sử dụng tỷ lệ khung hình cố định thay vì chiều cao cố định. Nhờ đó, quảng cáo biểu ngữ chiếm một phần nhất quán hơn trên màn hình các thiết bị và mang lại cơ hội cải thiện hiệu suất.
Khi sử dụng biểu ngữ thích ứng, xin lưu ý rằng biểu ngữ này sẽ luôn hiển thị ở một
kích thước không đổi cho một thiết bị và chiều rộng nhất định. Sau khi đã thử nghiệm bố cục trên một thiết bị nhất định, bạn có thể chắc chắn rằng kích thước quảng cáo đó sẽ không thay đổi. Tuy nhiên, kích thước của mẫu quảng cáo dạng biểu ngữ có thể thay đổi trên các thiết bị khác nhau. Do đó, bạn nên đảm bảo bố cục của mình có thể phù hợp với các kiểu bố cục có chiều cao khác nhau của quảng cáo.
Trong một số ít trường hợp, kích thước thích ứng đầy đủ có thể không hiển thị được và một quảng cáo
kích thước tiêu chuẩn sẽ được đặt ở giữa trong vùng này.
Trường hợp nên sử dụng biểu ngữ thích ứng
Biểu ngữ thích ứng được thiết kế để thay thế cho kích thước biểu ngữ 320x50 tiêu chuẩn của ngành, cũng như định dạng biểu ngữ thông minh mà các đơn vị quảng cáo này thay thế.
Các kích thước biểu ngữ này thường được dùng làm biểu ngữ cố định (loại biểu ngữ thường
xuất hiện ở phía trên cùng hoặc dưới cùng của màn hình. Đối với các biểu ngữ cố định như vậy, tỷ lệ khung hình khi sử dụng biểu ngữ thích ứng sẽ tương tự như tỷ lệ khung hình của quảng cáo chuẩn 320x50. Hãy xem các ảnh chụp màn hình dưới đây:

Biểu ngữ 320x50
|

Biểu ngữ thông minh
|

Biểu ngữ thích ứng
|
Biểu ngữ thích ứng sử dụng kích thước màn hình có sẵn hiệu quả hơn. Ngoài ra, so với biểu ngữ thông minh, bạn nên chọn biểu ngữ thích ứng vì:
Biểu ngữ thích ứng có thể hiển thị với chiều rộng đã chỉ định thay vì chiều rộng toàn màn hình, cho phép bạn xem xét vùng an toàn.
Biểu ngữ thích ứng lựa chọn chiều cao tối ưu cho từng thiết bị, thay vì sử dụng
chiều cao cố định trên các thiết bị có kích thước khác nhau. Việc này giúp giảm thiểu tác động của sự phân mảnh thiết bị.
Lưu ý khi triển khai
Khi triển khai biểu ngữ thích ứng trong ứng dụng của bạn, hãy lưu ý những điểm sau:
Bạn phải biết chiều rộng của khung hiển thị quảng cáo, và phải cân nhắc chiều rộng của thiết bị, cũng như mọi vùng an toàn (nếu có).
Đảm bảo rằng nền của chế độ xem quảng cáo được làm mờ để tuân thủ các chính sách của AdMob khi kích thước quảng cáo nhỏ hơn phân phát (kích thước này không lấp đầy vùng quảng cáo).
Đảm bảo bạn đang sử dụng phiên bản mới nhất của SDK C++ Quảng cáo trên thiết bị di động của Google. Để sử dụng tính năng dàn xếp, hãy sử dụng phiên bản mới nhất của mỗi bộ chuyển đổi dàn xếp.
Kích thước của biểu ngữ thích ứng hoạt động hiệu quả nhất khi sử dụng toàn bộ
chiều rộng có sẵn. Trong hầu hết các trường hợp, đây sẽ là chiều rộng tối đa của màn hình thiết bị đang sử dụng. Hãy nhớ cân nhắc vùng an toàn (nếu có).
SDK quảng cáo trên thiết bị di động của Google bằng C++ sẽ trả về chiều cao quảng cáo tối ưu cho chiều rộng nhất định trong một firebase::gma::AdSize
.
Có 3 phương pháp để đặt kích thước quảng cáo biểu ngữ thích ứng, trong đó một phương pháp dành cho biểu ngữ ngang, một phương pháp dành cho biểu ngữ dọc và một phương pháp dành cho hướng hiện tại tại thời điểm thực thi.
Kích thước được trả về cho một chiều rộng cụ thể trên một thiết bị cụ thể sẽ luôn giống nhau. Do đó, sau khi thử nghiệm bố cục trên một thiết bị cụ thể, bạn có thể chắc chắn rằng kích thước quảng cáo sẽ không thay đổi.
Chiều cao của biểu ngữ cố định không được lớn hơn 15% chiều cao của thiết bị và không được nhỏ hơn 50 điểm.
Bắt đầu nhanh
Làm theo các bước bên dưới để triển khai một biểu ngữ thích ứng cố định đơn giản.
Nhận một kích thước quảng cáo biểu ngữ thích ứng. Kích thước bạn nhận được sẽ được dùng để yêu cầu biểu ngữ thích ứng. Để có kích thước quảng cáo thích ứng, hãy đảm bảo rằng bạn:
Biết chiều rộng của thiết bị mà bạn đang sử dụng hoặc đặt chiều rộng riêng nếu bạn không muốn sử dụng chiều rộng toàn màn hình.
Sử dụng các phương thức tĩnh thích hợp trên lớp AdSize
, chẳng hạn như GetCurrentOrientationAnchoredAdaptiveBannerAdSize(uint32_t width)
để thu thập đối tượng AdSize
thích ứng cho hướng đã chọn.
Gọi Initialize()
trên AdView
bằng AdSize
thích ứng mà bạn đã tạo.
Hãy xem ví dụ đầy đủ bên dưới.
Tạo một đối tượng AdRequest
và tải biểu ngữ của bạn bằng cách sử dụng phương thức loadAd()
trên chế độ xem quảng cáo đã chuẩn bị, giống như cách bạn thực hiện với yêu cầu biểu ngữ thông thường.
Mã mẫu
Dưới đây là ví dụ về một AdView
sẽ tải một biểu ngữ thích ứng:
// 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);
Ở đây, hàm GetCurrentOrientationAnchoredAdaptiveBannerAdSize(uint32_t width)
được dùng để lấy kích thước của biểu ngữ ở một vị trí cố định cho hướng giao diện hiện tại. Để tải trước một biểu ngữ cố định theo một hướng nhất định, hãy sử dụng hàm có liên quan từ GetPortraitAnchoredAdaptiveBannerAdSize(uint32_t width)
và GetLandscapeAnchoredAdaptiveBannerAdSize(uint32_t width)
.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-09-06 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-09-06 UTC."],[[["\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)`."]]