Stili nativi
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Seleziona la piattaforma:
Android
iOS
Flutter
Le impostazioni degli stili nativi consentono a Google Ad Manager di gestire il rendering degli annunci nativi in base agli stili nativi specificati all'interno del prodotto. Innanzitutto, specifica le dimensioni e il targeting.
Poi aggiungi HTML, CSS e JavaScript per definire annunci adattabili
e produrre una visualizzazione di qualità su tutti gli schermi. Non devi eseguire
alcun rendering; Ad Manager applica automaticamente lo stile nativo corretto
per la destinazione. Gli stili nativi vengono implementati come gli annunci banner,
utilizzando un AdManagerAdView
. Possono essere utilizzati con dimensioni annuncio fisse
determinate in anticipo o con dimensioni annuncio flessibili determinate in fase di runtime.
Prerequisiti
- Plugin Flutter Google Mobile Ads versione 0.13.6 o successive
Questa guida presuppone una conoscenza pratica dell'SDK Google Mobile Ads.
Se non l'hai ancora fatto, consulta la nostra guida
Inizia.
Dimensioni fisse
Gli stili nativi con dimensioni fisse ti consentono di controllare la larghezza e l'altezza
dell'annuncio nativo. Per impostare una dimensione fissa:
Crea un elemento pubblicitario nell'UI di Ad Manager e seleziona una delle dimensioni predefinite dal menu a discesa del campo Size
.
Carica un AdManagerBannerAd
con le stesse dimensioni che hai impostato nel passaggio 1.
Consulta la documentazione relativa all'annuncio banner
per scoprire come creare un'istanza e caricare un annuncio.
Puoi visualizzare un elenco delle dimensioni e delle relative costanti AdSize
nella sezione Dimensioni banner.
Ecco un esempio di come specificare una dimensione fissa, ad esempio le dimensioni dell'annuncio
MEDIUM_RECTANGLE
(300 x 250):
AdManagerBannerAd ad = AdManagerBannerAd(
adUnitId: '<your-ad-unit>',
sizes: <AdSize>[AdSize.mediumRectangle],
request: AdManagerAdRequest(),
);
Dimensioni flessibili
In alcuni casi, una dimensione fissa potrebbe non essere appropriata. Ad esempio, potresti
volere che la larghezza dell'annuncio corrisponda ai contenuti della tua app, ma che la sua altezza
si adatti dinamicamente per adattarsi ai contenuti dell'annuncio. Per gestire questo caso,
puoi specificare Fluid
come dimensioni dell'annuncio nell'interfaccia utente di Ad Manager, il che
indica che le dimensioni dell'annuncio vengono determinate in fase di runtime nell'app.
L'SDK fornisce una costante speciale AdSize
, FLUID
, per gestire questo caso.
L'altezza dell'annuncio fluido viene determinata dinamicamente in base alla larghezza definita dal publisher, consentendo alla visualizzazione dell'annuncio sulla piattaforma di regolare la propria altezza in modo che corrisponda a quella della creatività.
Richiesta fluida
Utilizza FluidAdManagerBannerAd
per richiedere un annuncio fluido:
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();
},
),
Visualizzazione dell'annuncio fluido
Dopo aver caricato l'annuncio, utilizza FluidAdWidget
per visualizzare gli annunci adattabili. Regolerà
la sua altezza in modo che corrisponda alla visualizzazione dell'annuncio della piattaforma sottostante:
FluidAdWidget(
width: <your-width>,
ad: fluidAd,
);
Consulta un esempio di implementazione delle dimensioni flessibili degli annunci di Ad Manager nell'app di esempio
su GitHub.
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-09-06 UTC.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Mancano le informazioni di cui ho bisogno","missingTheInformationINeed","thumb-down"],["Troppo complicato/troppi passaggi","tooComplicatedTooManySteps","thumb-down"],["Obsoleti","outOfDate","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Problema relativo a esempi/codice","samplesCodeIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-06 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)."]]