Để thảo luận và đưa ra ý kiến phản hồi về các sản phẩm của chúng tôi, hãy tham gia kênh Discord chính thức của Ad Manager trong máy chủ Cộng đồng quảng cáo và đo lường của Google.
Chế độ cài đặt kiểu gốc cho phép Google Ad Manager xử lý quá trình hiển thị quảng cáo gốc dựa trên kiểu gốc mà bạn chỉ định trong sản phẩm. Trước tiên, hãy chỉ định kích thước và tiêu chí nhắm mục tiêu.
Sau đó, hãy thêm HTML, CSS và JavaScript để xác định những quảng cáo thích ứng và tạo ra một màn hình chất lượng trên tất cả các màn hình. Bạn không cần phải thực hiện bất kỳ thao tác kết xuất nào; Ad Manager sẽ tự động áp dụng kiểu gốc phù hợp cho đích đến. Các kiểu gốc được triển khai giống như quảng cáo biểu ngữ. Các quảng cáo này được kết xuất với kích thước quảng cáo linh hoạt được xác định trong thời gian chạy hoặc với kích thước quảng cáo cố định được xác định trước.
Bạn có thể sử dụng kích thước quảng cáo Linh hoạt trong giao diện người dùng Ad Manager để đạt được một quảng cáo tự động điều chỉnh cho phù hợp với nội dung của quảng cáo đó. Với chế độ cài đặt này, chiều rộng của quảng cáo sẽ khớp với nội dung của ứng dụng và chiều cao của quảng cáo sẽ điều chỉnh trong thời gian chạy để phù hợp với nội dung của quảng cáo. SDK cung cấp một hằng số AdSize đặc biệt, FLUID, để xử lý trường hợp này. Chiều cao của quảng cáo linh hoạt được xác định linh động dựa trên chiều rộng do nhà xuất bản xác định, cho phép khung hiển thị quảng cáo điều chỉnh chiều cao cho phù hợp với chiều cao của mẫu quảng cáo.
Tạo yêu cầu quảng cáo linh hoạt
Không giống như các định dạng quảng cáo khác, kích thước quảng cáo linh hoạt không có chiều rộng được xác định trước, vì vậy, hãy nhớ đặt rõ ràng layout_width của AdManagerAdView trong tệp bố cục XML của bạn:
Sau đây là cách triển khai để thực hiện yêu cầu quảng cáo:
Java
// fluidAdContainer is a ViewGroup that will be used to display the fluid native ad.AdManagerAdViewadView=(AdManagerAdView)fluidAdContainer;AdManagerAdRequestrequest=newAdManagerAdRequest.Builder().build();adView.loadAd(request);
// fluidAdContainer is a ViewGroup that will be used to display the fluid native ad.valadView=fluidAdContainerasAdManagerAdViewvalrequest=AdManagerAdRequest.Builder().build()adView.loadAd(request)
Kiểu gốc có kích thước cố định cho phép bạn kiểm soát chiều rộng và chiều cao của quảng cáo gốc. Để đặt kích thước cố định, hãy làm theo các bước sau:
Tạo một mục hàng trong giao diện người dùng Ad Manager và chọn một trong các kích thước được xác định trước trong trình đơn thả xuống của trường Size.
Trong tệp bố cục XML của ứng dụng, hãy đặt thuộc tính ads:adSize thành hằng số khớp với kích thước được xác định trước mà bạn đã chọn ở bước 1.
Bạn có thể xem danh sách các kích thước và hằng số AdSize tương ứng trong phần Kích thước cố định.
Dưới đây là ví dụ về cách chỉ định một kích thước cố định, chẳng hạn như kích thước quảng cáo MEDIUM_RECTANGLE (300x250), trong tệp bố cục:
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 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 native ads with fixed dimensions, like traditional banners, or opt for fluid sizes that adjust dynamically to the available screen space.\u003c/p\u003e\n"],["\u003cp\u003eFluid size ads are ideal when you want the ad width to match your content but need the height to automatically adapt to the ad creative.\u003c/p\u003e\n"],["\u003cp\u003eTo implement native styles, you'll utilize the \u003ccode\u003eAdManagerAdView\u003c/code\u003e component and specify the desired size in your app's layout file, similar to banner ads.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Mobile Ads SDK 8.1 or higher is required to leverage native style settings for your ad units.\u003c/p\u003e\n"]]],["Native styles in Google Ad Manager use HTML, CSS, and JavaScript to define responsive ads. To implement, use `AdManagerAdView`, similar to banner ads. Specify fixed sizes by creating a line item in the UI and selecting a predefined size. Set the `ads:adSize` attribute in the app's XML layout to the matching constant. Fluid sizes, determined at runtime, require setting \"Fluid\" in the UI and using the `FLUID` constant with a specified `layout_width`. Use Mobile Ads SDK version 8.1 or higher.\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) let\nGoogle Ad Manager handle the rendering of your native ads based on\nnative styles 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. They\nare rendered with a fluid ad size determined at runtime, or with a fixed\nad size determined ahead of time.\n\nPrerequisites\n\n- Complete the [Get started guide](/ad-manager/mobile-ads-sdk/android/quick-start).\n\nFluid size\n\nYou can use the Fluid ad size in the Ad Manager UI to achieve an ad that\ndynamically adjusts to fit its content. With this setting, the ad's width will\nmatch your app's content, and its height will adjust at runtime to accommodate\nthe ad's content. The SDK provides a special `AdSize` constant,\n[`FLUID`](/ad-manager/mobile-ads-sdk/android/reference/com/google/android/gms/ads/AdSize#FLUID()), to handle this case. The fluid ad size\nheight is dynamically determined based on the publisher defined width, allowing\nthe ad view to adjust its height to match that of the creative.\n\nCreate a fluid ad request\n\nUnlike other ad formats, the fluid ad size doesn't have a predefined width,\nso make sure to explicitly set the `layout_width` of the `AdManagerAdView`\nin your XML layout file: \n\n \u003ccom.google.android.gms.ads.admanager.AdManagerAdView\n android:id=\"@+id/fluid_ad_container\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"wrap_content\"\n android:layout_gravity=\"center_horizontal\"\n ads:adSize=\"FLUID\"\n ads:adUnitId=\"YOUR_AD_UNIT_ID\" /\u003e\n\n| **Note:** If you specify `wrap_content` for the `layout_width`, the `AdManagerAdView` width defaults to the width of its parent.\n\nHere's what the implementation looks like for making the ad request: \n\nJava \n\n // fluidAdContainer is a ViewGroup that will be used to display the fluid native ad.\n AdManagerAdView adView = (AdManagerAdView) fluidAdContainer;\n AdManagerAdRequest request = new AdManagerAdRequest.Builder().build();\n adView.loadAd(request); \n https://github.com/googleads/googleads-mobile-android-examples/blob/ccc290a583d7f552bdcf81ea76adc05beaa43f0b/java/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/NativeStylesSnippets.java#L28-L31\n\nKotlin \n\n // fluidAdContainer is a ViewGroup that will be used to display the fluid native ad.\n val adView = fluidAdContainer as AdManagerAdView\n val request = AdManagerAdRequest.Builder().build()\n adView.loadAd(request) \n https://github.com/googleads/googleads-mobile-android-examples/blob/ccc290a583d7f552bdcf81ea76adc05beaa43f0b/kotlin/advanced/APIDemo/app/src/main/java/com/google/android/gms/snippets/NativeStylesSnippets.kt#L28-L31\n\n\u003cbr /\u003e\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 drop-down.\n\n2. In your app's XML layout file, set the `ads:adSize` attribute to\n the constant that matches the predefined size you selected in step 1.\n You can see a list of sizes and their corresponding `AdSize` constants\n in the [Fixed size](/ad-manager/mobile-ads-sdk/android/banner/fixed_size)\n section.\n\nHere's an example of how to specify a fixed size, such as the\n`MEDIUM_RECTANGLE` (300x250) ad size, in your layout file: \n\n \u003ccom.google.android.gms.ads.admanager.AdManagerAdView\n android:id=\"@+id/ad_view_container\"\n android:layout_width=\"wrap_content\"\n android:layout_height=\"wrap_content\"\n android:layout_gravity=\"center_horizontal\"\n ads:adSize=\"MEDIUM_RECTANGLE\"\n ads:adUnitId=\"YOUR_AD_UNIT_ID\" /\u003e\n\n\u003cbr /\u003e"]]