Quảng cáo biểu ngữ thích ứng cùng dòng
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.
Chọn nền tảng:
Android
iOS
Flutter
Biểu ngữ thích ứng cho phép bạn chỉ định chiều rộng của quảng cáo để xác định kích thước quảng cáo tối ưu. Biểu ngữ thích ứng cũng tối đa hoá hiệu suất bằng cách tối ưu hoá kích thước quảng cáo cho từng thiết bị. Phương pháp này mang lại cơ hội để nâng cao hiệu suất.
So với biểu ngữ thích ứng cố định, biểu ngữ thích ứng cùng dòng có kích thước lớn hơn, chiều cao cao hơn và sử dụng chiều cao thay đổi thay vì chiều cao cố định. Biểu ngữ thích ứng trong dòng có chiều cao thay đổi và có thể bao gồm toàn bộ màn hình hoặc chiều cao tối đa mà bạn chỉ định.
Bạn đặt biểu ngữ thích ứng cùng dòng trong nội dung có thể cuộn, chẳng hạn như:

Trước khi bắt đầu
Trước khi tiếp tục, hãy đảm bảo bạn có những thông tin sau:
Triển khai biểu ngữ thích ứng
Không giống như biểu ngữ thích ứng cố định, biểu ngữ thích ứng cùng dòng tải bằng kích thước biểu ngữ thích ứng cùng dòng. Để tạo kích thước quảng cáo thích ứng cùng dòng, hãy hoàn tất các bước sau:
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 đối với lớp kích thước quảng cáo, chẳng hạn như
GADCurrentOrientationInlineBannerAdSizeWithWidth(CGFloat width)
để thu thập đối tượng kích thước quảng cáo thích ứng cùng dòng cho hướng đã chọn.
Swift
// Step 1: Create an inline adaptive banner ad size. This size is used to
// request your adaptive banner. You can pass in the width of the device, or
// set your own width. This example sets a static width.
let adSize = GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(320)
// Step 2: Create banner with the inline size and set ad unit ID.
let bannerView = GADBannerView(adSize: adSize)
bannerView.adUnitID = "AD_UNIT_ID"
bannerView.rootViewController = self
// Step 3: Load an ad.
let request = Request()
bannerView.load(request)
// TODO: Insert banner view in table view or scroll view, etc.
Objective-C
// Step 1: Create an inline adaptive banner ad size. This size is used to
// request your adaptive banner. You can pass in the width of the device, or set
// your own width. This example sets a static width.
GADAdSize adSize = GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(320);
// Step 2: Create banner with the inline size and set ad unit ID.
GADBannerView bannerView = [[GADBannerView alloc] initWithAdSize:adSize];
bannerView.adUnitID = @"AD_UNIT_ID";
bannerView.rootViewController = self;
// Step 3: Load an ad.
GADRequest *request = [GADRequest request];
[bannerView loadRequest:request];
// TODO: Insert banner view in table view or scroll view, etc.
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:
- Kích thước của biểu ngữ thích ứng cùng dò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, kích thước này là toàn bộ chiều rộng của màn hình thiết bị đang dùng hoặc toàn bộ chiều rộng của nội dung gốc trên biểu ngữ. Bạn phải biết chiều rộng của khung hiển thị để đặt quảng cáo, chiều rộng của thiết bị, chiều rộng của nội dung gốc và các vùng an toàn (nếu có).
Định hướng kích thước biểu ngữ thích ứng cùng dòng
Để tải trước một quảng cáo biểu ngữ thích ứng cùng dòng cho một hướng cụ thể, hãy sử dụng các phương thức sau:
Nếu ứng dụng của bạn hỗ trợ cả chế độ xem dọc và ngang, đồng thời bạn muốn tải trước một quảng cáo biểu ngữ thích ứng theo hướng hiện tại, hãy sử dụng GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(CGFloat width)
Phương thức này tải một quảng cáo theo hướng hiện tại.
Giới hạn chiều cao của biểu ngữ thích ứng cùng dòng
Theo mặc định, biểu ngữ thích ứng cùng dòng được khởi tạo mà không có giá trị maxHeight
sẽ có maxHeight
bằng chiều cao của thiết bị. Để giới hạn chiều cao của biểu ngữ thích ứng cùng dòng, hãy sử dụng phương thức GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(CGFloat width, CGFloat maxHeight)
.
Tài nguyên khác
Ví dụ trên GitHub
Tải ứng dụng mẫu xuống để xem biểu ngữ thích ứng cùng dòng hoạt động.
Swift
Objective-C
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-02 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-09-02 UTC."],[[["\u003cp\u003eInline adaptive banners are larger and taller than anchored adaptive banners, using variable heights to maximize screen space within scrolling content.\u003c/p\u003e\n"],["\u003cp\u003eTo implement inline adaptive banners, you'll need the Google Mobile Ads SDK 8.10.0 or higher and to have completed the Banner Ads getting started guide.\u003c/p\u003e\n"],["\u003cp\u003eThese banners are created using an inline adaptive banner size, determined by the device width or a custom width, and can have a maximum height set if desired.\u003c/p\u003e\n"],["\u003cp\u003eWhen using inline adaptive banners, ensure you're using the full available width and are aware of device, parent content, and safe area dimensions for optimal placement.\u003c/p\u003e\n"],["\u003cp\u003eInline adaptive banner ads can be preloaded for specific orientations or the current orientation, and their height can be limited using designated methods.\u003c/p\u003e\n"]]],["Inline adaptive banners, which are larger and use variable heights, optimize ad size for each device and are placed in scrolling content. Implementation involves determining the ad's width and using methods like `GADCurrentOrientationInlineBannerAdSizeWithWidth` or `GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight`. To use you must first create a size object, then the banner with the size object and ad id. Lastly, load the ad. These banners can be preloaded for specific or current orientations and may have a max height.\n"],null,["Select platform: [Android](/admob/android/banner/inline-adaptive \"View this page for the Android platform docs.\") [iOS](/admob/ios/banner/inline-adaptive \"View this page for the iOS platform docs.\") [Flutter](/admob/flutter/banner/inline-adaptive \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nAdaptive banners let you specify the width of an ad to determine the optimal\nad size. Adaptive banners also maximize performance by optimizing the ad size\nfor each device. This approach results in opportunities for\nimproved performance.\n\nCompared to anchored adaptive banners, inline adaptive banners are larger,\ntaller, and use variable instead of fixed heights. Inline adaptive banners are\nof variable height, and might encompass the entire screen or a maximum height\nthat you specify.\n\nYou place inline adaptive banners in scrolling content, for example:\n\nBefore you begin\n\nBefore continuing, make sure you have the following:\n\n- Completed the getting started guide, [Banner Ads](/admob/ios/banner).\n\nImplement adaptive banners\n\nUnlike anchored adaptive banners, inline adapter banners load using an inline\nadaptive banner size. To create an inline adaptive ad size, complete the\nfollowing:\n\n1. Get the width of the device in use, or set your own width if you don't want\n to use the full width of the screen.\n\n2. Use the appropriate static methods on the ad size class, such as\n\n `GADCurrentOrientationInlineBannerAdSizeWithWidth(CGFloat width)`\n\n to get an inline adaptive ad size object for the chosen orientation.\n\n \u003cbr /\u003e\n\n Swift \n\n // Step 1: Create an inline adaptive banner ad size. This size is used to\n // request your adaptive banner. You can pass in the width of the device, or\n // set your own width. This example sets a static width.\n let adSize = GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(320)\n // Step 2: Create banner with the inline size and set ad unit ID.\n let bannerView = GADBannerView(adSize: adSize)\n bannerView.adUnitID = \"\u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\"\n bannerView.rootViewController = self\n\n // Step 3: Load an ad.\n let request = Request()\n bannerView.load(request)\n // TODO: Insert banner view in table view or scroll view, etc.\n\n Objective-C \n\n // Step 1: Create an inline adaptive banner ad size. This size is used to\n // request your adaptive banner. You can pass in the width of the device, or set\n // your own width. This example sets a static width.\n GADAdSize adSize = GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(320);\n // Step 2: Create banner with the inline size and set ad unit ID.\n GADBannerView bannerView = [[GADBannerView alloc] initWithAdSize:adSize];\n bannerView.adUnitID = @\"\u003cvar class=\"readonly\" translate=\"no\"\u003eAD_UNIT_ID\u003c/var\u003e\";\n bannerView.rootViewController = self;\n\n // Step 3: Load an ad.\n GADRequest *request = [GADRequest request];\n [bannerView loadRequest:request];\n // TODO: Insert banner view in table view or scroll view, etc.\n\n When implementing adaptive banners in your app, note these points:\n - The inline adaptive banner sizes work best when using the full available width. In most cases, this size is the full width of the device screen in use, or the full width of the banner's parent content. You must know the width of the view to place in the ad, the device width, the parent content width, and applicable safe areas.\n\n Orient inline adaptive banner size\n\n To preload an inline adaptive banner ad for a specific orientation, use the\n following methods:\n - [`GADPortraitInlineAdaptiveBannerAdSizeWithWidth(CGFloat width)`](/admob/ios/api/reference/Functions#gadportraitinlineadaptivebanneradsizewithwidth)\n\n - [`GADLandscapeInlineAdaptiveBannerAdSizeWithWidth(CGFloat width)`](/admob/ios/api/reference/Functions#gadlandscapeinlineadaptivebanneradsizewithwidth)\n\n If your app supports both portrait and landscape views, and you want to preload\n an adaptive banner ad in the current orientation, use\n\n [`GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(CGFloat width)`](/admob/ios/api/reference/Functions#gadcurrentorientationinlineadaptivebanneradsizewithwidth)\n\n This method loads an ad in the current orientation.\n\n Limit inline adaptive banner height\n\n By default, inline adaptive banners instantiated without a `maxHeight` value\n have a `maxHeight` equal to the device height. To limit the inline adaptive\n banner height, use the\n\n [`GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(CGFloat width, CGFloat maxHeight)`](/admob/ios/api/reference/Functions#gadinlineadaptivebanneradsizewithwidthandmaxheight)\n\n method.\n\n Additional resources\n\n Examples on GitHub\n\n Download the sample application to see inline adaptive banners in action.\n\n [Swift](//github.com/googleads/googleads-mobile-ios-examples/tree/main/Swift/advanced/InlineAdaptiveBannerExample)\n [Objective-C](//github.com/googleads/googleads-mobile-ios-examples/tree/main/Objective-C/advanced/InlineAdaptiveBannerExample)"]]