โฆษณาแบนเนอร์ขนาดคงที่
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เลือกแพลตฟอร์ม:
Android
iOS
Flutter
Google Mobile Ads SDK รองรับขนาดโฆษณาคงที่สำหรับกรณีที่โฆษณาแบนเนอร์แบบปรับขนาดได้ไม่ตรงกับความต้องการของคุณ
ตารางต่อไปนี้แสดงขนาดแบนเนอร์มาตรฐาน
ขนาดในหน่วย dp (กว้างxสูง) |
คำอธิบาย |
ความพร้อมใช้งาน |
ค่าคงที่ AdSize |
320x50 |
ป้ายประกาศ |
โทรศัพท์และแท็บเล็ต |
GADAdSizeBanner |
320x100 |
แบนเนอร์ขนาดใหญ่ |
โทรศัพท์และแท็บเล็ต |
GADAdSizeLargeBanner |
300x250 |
สี่เหลี่ยมผืนผ้าขนาดกลางของ IAB |
โทรศัพท์และแท็บเล็ต |
GADAdSizeMediumRectangle |
468x60 |
แบนเนอร์ขนาดเต็มของ IAB |
แท็บเล็ต |
GADAdSizeFullBanner |
728x90 |
ลีดเดอร์บอร์ดของ IAB |
แท็บเล็ต |
GADAdSizeLeaderboard |
หากต้องการกำหนดขนาดแบนเนอร์ที่กำหนดเอง ให้ตั้งค่าขนาดโดยใช้ GADAdSizeFromCGSize
ดังนี้
Swift
let adSize = adSizeFor(cgSize: CGSize(width: 250, height: 250))
Objective-C
GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(250, 250));
ตัวอย่างโฆษณาแบนเนอร์ขนาดคงที่
Swift
Objective-C
ขนาดโฆษณาที่กำหนดเอง
นอกจากหน่วยโฆษณามาตรฐานแล้ว Google Ad Manager ยังให้คุณแสดงหน่วยโฆษณาขนาดใดก็ได้
ในแอป ขนาดโฆษณา (ความกว้าง ความสูง) ที่กำหนดสำหรับคำขอโฆษณา
ควรตรงกับขนาดของมุมมองโฆษณา (GAMBannerView
) ที่แสดงใน
แอป หากต้องการตั้งค่าขนาดที่กำหนดเอง ให้ใช้ GADAdSizeFromCGSize
Swift
// Define custom GADAdSize of 250x250 for GAMBannerView.
let customAdSize = adSizeFor(cgSize: CGSize(width: 250, height: 250))
bannerView = GAMBannerView(adSize: customAdSize)
Objective-C
// Define custom GADAdSize of 250x250 for GAMBannerView
GADAdSize customAdSize = GADAdSizeFromCGSize(CGSizeMake(250, 250));
self.bannerView = [[GAMBannerView alloc] initWithAdSize:customAdSize];
โฆษณาหลายขนาด
Ad Manager ช่วยให้คุณระบุขนาดโฆษณาหลายขนาดซึ่งอาจมีสิทธิ์แสดง
ในGAMBannerView
ได้ คุณต้องทำ 3 ขั้นตอนต่อไปนี้เพื่อใช้ฟีเจอร์นี้
ใน UI ของ Ad Manager ให้สร้างรายการโฆษณาที่กำหนดเป้าหมายไปยังหน่วยโฆษณาเดียวกันซึ่ง
เชื่อมโยงกับครีเอทีฟโฆษณาที่มีขนาดแตกต่างกัน
ในแอป ให้ตั้งค่าพร็อพเพอร์ตี้ validAdSizes
ใน GAMBannerView
ดังนี้
Swift
// Define an optional array of GADAdSize to specify all valid sizes that are appropriate
// for this slot. Never create your own GADAdSize directly. Use one of the
// predefined standard ad sizes (such as GADAdSizeBanner), or create one using
// the GADAdSizeFromCGSize method.
//
// Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note
// that all desired sizes should be included in the validAdSizes array.
bannerView.validAdSizes = [NSValueFromGADAdSize(AdSizeBanner),
NSValueFromGADAdSize(AdSizeMediumRectangle),
NSValueFromGADAdSize(adSizeFor(cgSize: CGSize(width: 120, height: 20)))]
Objective-C
// Define an optional array of GADAdSize to specify all valid sizes that are appropriate
// for this slot. Never create your own GADAdSize directly. Use one of the
// predefined standard ad sizes (such as GADAdSizeBanner), or create one using
// the GADAdSizeFromCGSize method.
//
// Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note
// that all desired sizes should be included in the validAdSizes array.
self.bannerView.validAdSizes = @[
NSValueFromGADAdSize(GADAdSizeBanner),
NSValueFromGADAdSize(GADAdSizeMediumRectangle),
NSValueFromGADAdSize(GADAdSizeFromCGSize(CGSizeMake(120, 20)))
];
ใช้เมธอด GADAdSizeDelegate
เพื่อตรวจหาการเปลี่ยนแปลงขนาดโฆษณา
Swift
public func bannerView(_ bannerView: BannerView, willChangeAdSizeTo size: AdSize)
Objective-C
- (void)bannerView:(GAMBannerView *)view willChangeAdSizeTo:(GADAdSize)size;
อย่าลืมตั้งค่าผู้รับมอบสิทธิ์ก่อนส่งคำขอโฆษณา
Swift
bannerView.adSizeDelegate = self
Objective-C
self.bannerView.adSizeDelegate = self;
ตัวอย่างโฆษณาหลายขนาด
Swift
Objective-C
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-25 UTC
[null,null,["อัปเดตล่าสุด 2025-08-25 UTC"],[[["\u003cp\u003eThe Google Mobile Ads SDK offers fixed ad sizes as an alternative to adaptive banners, including standard options like Banner (320x50) and Leaderboard (728x90).\u003c/p\u003e\n"],["\u003cp\u003eYou can define custom banner sizes using \u003ccode\u003eGADAdSizeFromCGSize\u003c/code\u003e by specifying the desired width and height.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Ad Manager supports serving multiple ad sizes to a single ad unit by configuring valid sizes in your app and creating corresponding line items in Ad Manager.\u003c/p\u003e\n"],["\u003cp\u003eTo handle ad size changes dynamically, implement the \u003ccode\u003eGADAdSizeDelegate\u003c/code\u003e and its \u003ccode\u003ebannerView(_:willChangeAdSizeTo:)\u003c/code\u003e method.\u003c/p\u003e\n"]]],[],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/banner/fixed-size \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/banner/fixed-size \"View this page for the iOS platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/banner/fixed-size \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nThe Google Mobile Ads SDK supports fixed ad sizes for situations where adaptive\nbanners ads don't meet your needs.\n\nThe following table lists the standard banner sizes.\n\n| Size in dp (WxH) | Description | Availability | AdSize constant |\n|------------------|----------------------|--------------------|----------------------------|\n| 320x50 | Banner | Phones and tablets | `GADAdSizeBanner` |\n| 320x100 | Large banner | Phones and tablets | `GADAdSizeLargeBanner` |\n| 300x250 | IAB medium rectangle | Phones and tablets | `GADAdSizeMediumRectangle` |\n| 468x60 | IAB full-size banner | Tablets | `GADAdSizeFullBanner` |\n| 728x90 | IAB leaderboard | Tablets | `GADAdSizeLeaderboard` |\n\nTo define a custom banner size, set your size using [`GADAdSizeFromCGSize`](/ad-manager/mobile-ads-sdk/ios/api/reference/Functions): \n\nSwift \n\n let adSize = adSizeFor(cgSize: CGSize(width: 250, height: 250))\n\nObjective-C \n\n GADAdSize size = GADAdSizeFromCGSize(CGSizeMake(250, 250));\n\nFixed size banner ads example\n\n[Swift](//github.com/googleads/googleads-mobile-ios-examples/blob/main/Swift/advanced/APIDemo/APIDemo/AdMobBannerSizesViewController.swift)\n[Objective-C](//github.com/googleads/googleads-mobile-ios-examples/blob/main/Objective-C/advanced/APIDemo/APIDemo/AdMobBannerSizesViewController.m)\n\nCustom ad size\n\nIn addition to the standard ad units, Google Ad Manager lets you serve any sized\nad unit into an app. The ad size (width, height) defined for an ad request\nshould match the dimensions of the ad view (`GAMBannerView`) displayed on the\napp. To set a custom size, use [`GADAdSizeFromCGSize`](/ad-manager/mobile-ads-sdk/ios/api/reference/Functions#/c:@F@CGSizeFromGADAdSize). \n\nSwift \n\n // Define custom GADAdSize of 250x250 for GAMBannerView.\n let customAdSize = adSizeFor(cgSize: CGSize(width: 250, height: 250))\n bannerView = GAMBannerView(adSize: customAdSize)\n\nObjective-C \n\n // Define custom GADAdSize of 250x250 for GAMBannerView\n GADAdSize customAdSize = GADAdSizeFromCGSize(CGSizeMake(250, 250));\n self.bannerView = [[GAMBannerView alloc] initWithAdSize:customAdSize];\n\nMultiple ad sizes\n\nAd Manager lets you specify multiple ad sizes which could be eligible to serve\ninto a `GAMBannerView`. There are three steps needed in order to use this\nfeature:\n\n1. In the Ad Manager UI, create a line item targeting the same ad unit that is\n associated with different size creatives.\n\n2. In your app, set the `validAdSizes` property on `GAMBannerView`:\n\n Swift \n\n // Define an optional array of GADAdSize to specify all valid sizes that are appropriate\n // for this slot. Never create your own GADAdSize directly. Use one of the\n // predefined standard ad sizes (such as GADAdSizeBanner), or create one using\n // the GADAdSizeFromCGSize method.\n //\n // Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note\n // that all desired sizes should be included in the validAdSizes array.\n bannerView.validAdSizes = [NSValueFromGADAdSize(AdSizeBanner),\n NSValueFromGADAdSize(AdSizeMediumRectangle),\n NSValueFromGADAdSize(adSizeFor(cgSize: CGSize(width: 120, height: 20)))]\n\n Objective-C \n\n // Define an optional array of GADAdSize to specify all valid sizes that are appropriate\n // for this slot. Never create your own GADAdSize directly. Use one of the\n // predefined standard ad sizes (such as GADAdSizeBanner), or create one using\n // the GADAdSizeFromCGSize method.\n //\n // Note: Ensure that the allocated GAMBannerView is defined with an ad size. Also note\n // that all desired sizes should be included in the validAdSizes array.\n self.bannerView.validAdSizes = @[\n NSValueFromGADAdSize(GADAdSizeBanner),\n NSValueFromGADAdSize(GADAdSizeMediumRectangle),\n NSValueFromGADAdSize(GADAdSizeFromCGSize(CGSizeMake(120, 20)))\n ];\n\n3. Implement the `GADAdSizeDelegate` method to detect an ad size change.\n\n Swift \n\n public func bannerView(_ bannerView: BannerView, willChangeAdSizeTo size: AdSize)\n\n Objective-C \n\n - (void)bannerView:(GAMBannerView *)view willChangeAdSizeTo:(GADAdSize)size;\n\n Remember to set the delegate before making the request for an ad. \n\n Swift \n\n bannerView.adSizeDelegate = self\n\n Objective-C \n\n self.bannerView.adSizeDelegate = self;\n\nMultiple ad sizes example\n\n[Swift](//github.com/googleads/googleads-mobile-ios-examples/blob/main/Swift/advanced/APIDemo/APIDemo/AdManagerMultipleAdSizesViewController.swift)\n[Objective-C](//github.com/googleads/googleads-mobile-ios-examples/blob/main/Objective-C/advanced/APIDemo/APIDemo/GAMMultipleAdSizesViewController.m)"]]