สไตล์โฆษณาเนทีฟ
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เลือกแพลตฟอร์ม:
Android
iOS
Flutter
การตั้งค่าสไตล์โฆษณาเนทีฟ
ช่วยให้ Google Ad Manager จัดการการแสดงผลโฆษณาเนทีฟตามสไตล์โฆษณาเนทีฟ
ที่คุณระบุไว้ในผลิตภัณฑ์ได้ ก่อนอื่น ให้ระบุขนาดและการกำหนดเป้าหมาย
จากนั้นเพิ่ม HTML, CSS และ JavaScript เพื่อกำหนดโฆษณาที่ปรับเปลี่ยนตามพื้นที่โฆษณา
และแสดงผลคุณภาพในทุกหน้าจอ คุณไม่จำเป็นต้องทำการแสดงผลใดๆ เนื่องจาก Ad Manager จะใช้สไตล์โฆษณาเนทีฟที่เหมาะสมกับปลายทางโดยอัตโนมัติ
การติดตั้งใช้งานสไตล์โฆษณาเนทีฟจะเหมือนกับโฆษณาแบนเนอร์
โดยใช้ AdManagerAdView
ใช้กับขนาดโฆษณาคงที่ที่กำหนดไว้ล่วงหน้า หรือขนาดโฆษณาแบบไหลที่กำหนดในรันไทม์ได้
ข้อกำหนดเบื้องต้น
- ปลั๊กอิน Flutter สำหรับโฆษณาในอุปกรณ์เคลื่อนที่ของ Google เวอร์ชัน 0.13.6 ขึ้นไป
คู่มือนี้ถือว่าคุณมีความรู้พื้นฐานเกี่ยวกับ Google Mobile Ads SDK
หากยังไม่ได้ดำเนินการ โปรดดูคำแนะนำในคู่มือเริ่มต้นใช้งาน
ขนาดคงที่
สไตล์โฆษณาเนทีฟที่มีขนาดคงที่ช่วยให้คุณควบคุมความกว้างและความสูง
ของโฆษณาเนทีฟได้ หากต้องการตั้งค่าขนาดคงที่ ให้ทำตามขั้นตอนต่อไปนี้
สร้างรายการโฆษณาใน UI ของ Ad Manager แล้วเลือกขนาดที่กำหนดไว้ล่วงหน้าจากเมนูแบบเลื่อนลงของช่อง Size
โหลด AdManagerBannerAd
ที่มีขนาดเดียวกับที่คุณตั้งค่าไว้ในขั้นตอนที่ 1
ดูเอกสารประกอบโฆษณาแบนเนอร์
เกี่ยวกับวิธีสร้างอินสแตนซ์และโหลดโฆษณา
คุณดูรายการขนาดและAdSize
ค่าคงที่
ที่เกี่ยวข้องได้ในส่วนขนาดแบนเนอร์
ต่อไปนี้คือตัวอย่างวิธีระบุขนาดคงที่ เช่น ขนาดโฆษณา
MEDIUM_RECTANGLE
(300x250)
AdManagerBannerAd ad = AdManagerBannerAd(
adUnitId: '<your-ad-unit>',
sizes: <AdSize>[AdSize.mediumRectangle],
request: AdManagerAdRequest(),
);
ขนาดแบบไหล
ในบางกรณี ขนาดคงที่อาจไม่เหมาะสม เช่น คุณอาจต้องการให้ความกว้างของโฆษณาตรงกับเนื้อหาของแอป แต่ต้องการให้ความสูงปรับแบบไดนามิกเพื่อให้พอดีกับเนื้อหาของโฆษณา หากต้องการจัดการกรณีนี้
คุณสามารถระบุ Fluid
เป็นขนาดโฆษณาใน UI ของ Ad Manager ซึ่ง
จะกำหนดว่าขนาดของโฆษณาจะกำหนดที่รันไทม์ในแอป
SDK มีค่าคงที่ AdSize
พิเศษ FLUID
เพื่อจัดการกรณีนี้
ความสูงของขนาดโฆษณาแบบไหลจะกำหนดแบบไดนามิกตามความกว้างที่ผู้เผยแพร่โฆษณากำหนด ซึ่งจะช่วยให้มุมมองโฆษณาของแพลตฟอร์มปรับความสูงให้ตรงกับความสูงของครีเอทีฟโฆษณาได้
คำขอแบบยืดหยุ่น
ใช้ FluidAdManagerBannerAd
เพื่อขอโฆษณาแบบยืดหยุ่น
final fluidAd = FluidAdManagerBannerAd(
adUnitId: '<your-ad-unit>',
request: AdManagerAdRequest(),
listener: AdManagerBannerAdListener(
onAdLoaded: (Ad ad) {
print('$_fluidAd loaded.');
},
onAdFailedToLoad: (Ad ad, LoadAdError error) {
print('$_fluidAd failedToLoad: $error');
ad.dispose();
},
),
การแสดงโฆษณาแบบไหล
หลังจากโหลดโฆษณาแล้ว ให้ใช้ FluidAdWidget
เพื่อแสดงโฆษณาแบบยืดหยุ่น โดยจะ
ปรับความสูงให้ตรงกับมุมมองโฆษณาของแพลตฟอร์มพื้นฐาน
FluidAdWidget(
width: <your-width>,
ad: fluidAd,
);
ดูตัวอย่างการใช้งานขนาดโฆษณาแบบไหลของ Ad Manager ในแอปตัวอย่าง
ใน Github
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-09-02 UTC
[null,null,["อัปเดตล่าสุด 2025-09-02 UTC"],[[["\u003cp\u003eNative style settings in Google Ad Manager allow you to customize the look and feel of your native ads using HTML, CSS, and JavaScript for a seamless user experience.\u003c/p\u003e\n"],["\u003cp\u003eYou can define fixed-size native ads by specifying their dimensions in the Ad Manager UI and using corresponding \u003ccode\u003eAdSize\u003c/code\u003e constants when loading the ad in your app.\u003c/p\u003e\n"],["\u003cp\u003eAlternatively, fluid-size native ads dynamically adjust their height based on the width you provide, ensuring responsiveness across different screens using the \u003ccode\u003eFluidAdManagerBannerAd\u003c/code\u003e and \u003ccode\u003eFluidAdWidget\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTo implement native ads, you need Google Mobile Ads Flutter Plugin version 0.13.6 or higher and basic familiarity with the Google Mobile Ads SDK.\u003c/p\u003e\n"]]],["Google Ad Manager renders native ads based on specified styles. Users define ad size and targeting, then add HTML, CSS, and JavaScript for responsive design. Fixed ad sizes are set in the Ad Manager UI and loaded using `AdManagerBannerAd` with corresponding `AdSize` constants. Fluid ads use `Fluid` in the UI and the `FLUID` constant, with `FluidAdManagerBannerAd` for requests and `FluidAdWidget` for display, dynamically adjusting the height.\n"],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/native/styles \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/native/styles \"View this page for the iOS platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/flutter/native/styles \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\n[Native style settings](//support.google.com/admanager/answer/6366914)\nenable Google Ad Manager to handle the rendering of your native ads based on native\nstyles you specify within the product. First, specify size and targeting.\nThen add HTML, CSS, and JavaScript to define ads that are responsive\nand produce a quality display across all screens. You don't need to do\nany of the rendering; Ad Manager automatically applies the right native style\nfor the destination. Native styles are implemented just like banner ads,\nusing a `AdManagerAdView`. They can be used with a fixed ad\nsize determined ahead of time, or a fluid ad size determined at runtime.\n\nPrerequisites\n\n- Google Mobile Ads Flutter Plugin version 0.13.6 or higher\n\nThis guide assumes some working knowledge of the Google Mobile Ads SDK.\nIf you haven't already done so, consider running through our\n[Get Started](/ad-manager/mobile-ads-sdk/flutter/quick-start) guide.\n\nFixed size\n\nNative styles with a fixed size allow you to control the width and height\nof the native ad. To set a fixed size, follow these steps:\n\n1. Create a line item in the Ad Manager UI and select one of the\n predefined sizes from the `Size` field dropdown.\n\n2. Load an `AdManagerBannerAd` with the same size you set up in step 1.\n See the [Banner Ad](/ad-manager/mobile-ads-sdk/flutter/banner/get-started#instantiate_ad)\n documentation for how to instantiate and load an ad.\n You can see a list of sizes and their corresponding `AdSize` constants\n in the [Banner size](/ad-manager/mobile-ads-sdk/flutter/banner/get-started#banner_sizes)\n section.\n\nHere's an example of how to specify a fixed size, such as the\n`MEDIUM_RECTANGLE` (300x250) ad size: \n\n AdManagerBannerAd ad = AdManagerBannerAd(\n adUnitId: '\u003cyour-ad-unit\u003e',\n sizes: \u003cAdSize\u003e[AdSize.mediumRectangle],\n request: AdManagerAdRequest(),\n );\n\nFluid size\n\nIn some cases, a fixed size may not make sense. For example, you may\nwant the width of the ad to match your app's content, but need its height\nto dynamically adjust to fit the ad's content. To handle this case,\nyou can specify `Fluid` as the ad size in the Ad Manager UI, which\ndesignates that the size of the ad is determined at runtime in the app.\nThe SDK provides a special `AdSize` constant, `FLUID`, to handle this case.\nThe fluid ad size height is dynamically determined based on the publisher\ndefined width, allowing the platform ad view to adjust its height to match that\nof the creative.\n\nFluid request\n\nUse `FluidAdManagerBannerAd` to request a fluid ad: \n\n final fluidAd = FluidAdManagerBannerAd(\n adUnitId: '\u003cyour-ad-unit\u003e',\n request: AdManagerAdRequest(),\n listener: AdManagerBannerAdListener(\n onAdLoaded: (Ad ad) {\n print('$_fluidAd loaded.');\n },\n onAdFailedToLoad: (Ad ad, LoadAdError error) {\n print('$_fluidAd failedToLoad: $error');\n ad.dispose();\n },\n ),\n\nDisplaying the fluid ad\n\nAfter your ad is loaded, use `FluidAdWidget` to display fluid ads. It will\nadjust its height to match the underlying platform ad view: \n\n FluidAdWidget(\n width: \u003cyour-width\u003e,\n ad: fluidAd,\n );\n\nSee an example implementation of Ad Manager Fluid ad size in the example app\non [Github](https://github.com/googleads/googleads-mobile-flutter/blob/master/packages/google_mobile_ads/example/lib/fluid_example.dart)."]]