ネイティブ テンプレート
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
ネイティブ テンプレートをダウンロードする
ネイティブ広告を使用すると、広告をカスタマイズして、質の高いユーザー エクスペリエンスを提供することができます。ユーザー エクスペリエンスが向上すると、エンゲージメントが促進され、全体的な収益の拡大にもつながります。
ネイティブ広告を最大限に活かすには、広告レイアウトがアプリの他の部分に自然に馴染むようなスタイルにすることが重要です。初めての方向けに、ネイティブ テンプレートが用意されています。
ネイティブ テンプレートとは、ネイティブ広告として使用できるビューであり、コーディングが完成された状態で提供されるため、実装と変更を簡単に行えます。初めてのネイティブ広告を数分で実装でき、大量のコードに煩わされることなく短時間でデザインをカスタマイズできます。このテンプレートは、ニュース フィード内で使用するリサイクラー ビューや、ダイアログ、アプリ内の他の場所など、どこでも好きな場所に配置できます。
ネイティブ テンプレートは、Android Studio のモジュールとして提供されているので、プロジェクトに簡単に組み込んで自由に使用できます。
テンプレートのサイズ
テンプレートのサイズには、小と中の 2 種類があります。どちらも TemplateView
クラスを使用し、アスペクト比は固定されています。テンプレートは親ビューの幅いっぱいになるように調整されます。
小サイズのテンプレート
@layout/gnt_small_template_view
小サイズのテンプレートは、リサイクラー ビューや帯状の広告ビューなどに最適です。たとえば、インフィード広告に使用できます。

中サイズのテンプレート
@layout/gnt_medium_template_view
中サイズのテンプレートは、ページビューの 1/2~3/4 のサイズでの使用を想定されていますが、フィードでも使用できます。ランディング ページやスプラッシュ ページに適しています。
プレースメントは、さまざまな場所をお試しいただけます。必要に応じて、ソースコードや XML ファイルを変更することもできます。

ネイティブ広告テンプレートのインストール
ネイティブ テンプレートをインストールするには、ZIP ファイルをダウンロード(GitHub のクローンまたはダウンロード オプションを使用して)して、既存の Android Studio プロジェクトにモジュールをインポートしてください。
[File] > [New] > [Import Module] を選択します。
nativetemplates
フォルダを選択します。

アプリレベルの build.gradle
ファイルに次の行を追加します。
dependencies {
...
implementation project(':nativetemplates')
...
}
ネイティブ広告テンプレートの使用
テンプレートは、通常のビューグループと同様に、任意のレイアウト XML ファイルで使用できます。

テンプレートを使用するには、次の 2 つの手順を行います。
まずは、レイアウトの一部としてテンプレートを含めます。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
tools:showIn="@layout/activity_main" >
<!-- This is your template view -->
<com.google.android.ads.nativetemplates.TemplateView
android:id="@+id/my_template"
<!-- this attribute determines which template is used. The other option is
@layout/gnt_medium_template_view -->
app:gnt_template_type="@layout/gnt_small_template_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
...
</LinearLayout>
次に、読み込んだネイティブ広告をテンプレートに表示します。
MobileAds.initialize(this);
AdLoader adLoader = new AdLoader.Builder(this, "ca-app-pub-3940256099942544/2247696110")
.forNativeAd(new NativeAd.OnNativeAdLoadedListener() {
@Override
public void onNativeAdLoaded(NativeAd nativeAd) {
NativeTemplateStyle styles = new
NativeTemplateStyle.Builder().withMainBackgroundColor(background).build();
TemplateView template = findViewById(R.id.my_template);
template.setStyles(styles);
template.setNativeAd(nativeAd);
}
})
.build();
adLoader.loadAd(new AdRequest.Builder().build());
スタイル ディクショナリ キー
テンプレートのスタイルを設定するには、従来のレイアウト XML を使用する方法と、NativeTemplateStyle.Builder
オブジェクトを使用する方法の 2 つあります。上記のコードサンプルでは、NativeTemplateStyle.Builder
オブジェクトを使用して主な背景色を設定していますが、他にもさまざまなオプションが用意されています。利用できるビルダー メソッドについては、以下の表をご覧ください。ビルダーは、XML レイアウトのスタイルをオーバーライドする NativeTemplateStyle
オブジェクトを返します。XML レイアウトの gnt_small_template.xml
と gnt_medium_template.xml
では、一般的な Android スタイリング パラメータが使用されます。
ネイティブ テンプレートのスタイルに使用するビルダーのメソッド |
withCallToActionTextTypeface
|
Typeface callToActionTextTypeface
行動を促すフレーズの書体。
|
withCallToActionTextSize
|
float callToActionTextSize
行動を促すフレーズのテキストのサイズ。
|
withCallToActionTypefaceColor
|
int callToActionTypefaceColor
行動を促すフレーズのテキストの色。
|
withCallToActionBackgroundColor
|
ColorDrawable callToActionBackgroundColor
行動を促すフレーズの背景色。
|
withPrimaryTextTypeface
|
Typeface primaryTextTypeface
1 行目のテキストの書体。
|
withPrimaryTextSize
|
float primaryTextSize
1 行目のテキストのサイズ。
|
withPrimaryTextTypefaceColor
|
int primaryTextTypefaceColor
1 行目のテキストの色。
|
withPrimaryTextBackgroundColor
|
ColorDrawable primaryTextBackgroundColor
1 行目のテキストの背景色。
|
withSecondaryTextTypeface
|
Typeface secondaryTextTypeface
2 行目のテキストの書体。
|
withSecondaryTextSize
|
float secondaryTextSize
2 行目のテキストのサイズ。
|
withSecondaryTextTypefaceColor
|
int secondaryTextTypefaceColor
2 行目のテキストの色。
|
withSecondaryTextBackgroundColor
|
ColorDrawable secondaryTextBackgroundColor
2 行目のテキストの背景色。
|
withTertiaryTextTypeface
|
Typeface tertiaryTextTypeface
3 行目のテキストの書体。
|
withTertiaryTextSize
|
float tertiaryTextSize
3 行目のテキストのサイズ。
|
withTertiaryTextTypefaceColor
|
int tertiaryTextTypefaceColor
3 行目のテキストの色。
|
withTertiaryTextBackgroundColor
|
ColorDrawable tertiaryTextBackgroundColor
3 行目のテキストの背景色。
|
withMainBackgroundColor
|
ColorDrawable mainBackgroundColor
主な背景色。
|
投稿
ネイティブ広告を簡単に開発できるようにネイティブ テンプレートを作成しました。
ぜひ皆様も新しいテンプレートや機能を GitHub レポジトリに投稿してください。プルリクエストを送っていただければ確認いたします。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-09-02 UTC。
[null,null,["最終更新日 2025-09-02 UTC。"],[[["\u003cp\u003eNative Templates are pre-built ad views designed for quick implementation and customization in Android apps, helping create a more natural user experience.\u003c/p\u003e\n"],["\u003cp\u003eThese templates come in small and medium sizes, suitable for various placements like recycler views and landing pages, offering flexibility in integration.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can easily install these templates as an Android Studio module by downloading them from GitHub and adding a dependency in their project's \u003ccode\u003ebuild.gradle\u003c/code\u003e file.\u003c/p\u003e\n"],["\u003cp\u003eUsing templates involves including them in your layout XML and then populating them with a native ad when it's loaded, further customizable with styling options.\u003c/p\u003e\n"],["\u003cp\u003eYou can contribute by adding new templates or features through pull requests on the GitHub repository, fostering collaborative development.\u003c/p\u003e\n"]]],["Native Templates provide pre-built views for native ads, simplifying their implementation and customization. To use them, download the module from GitHub and import it into your Android Studio project. There are two template sizes: small (`gnt_small_template_view`) and medium (`gnt_medium_template_view`). Integrate a template into your layout XML and then use `NativeTemplateStyle.Builder` to style it using different text size, color, background and style properties. Next load your native ad by calling `setNativeAd` and make sure you know how to load native ad.\n"],null,["Select platform: [Android](/admob/android/native/templates \"View this page for the Android platform docs.\") [iOS](/admob/ios/native/templates \"View this page for the iOS platform docs.\") [Flutter](/admob/flutter/native/templates \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\n[Download Native Templates](//github.com/googleads/googleads-mobile-android-native-templates)\n| **Key Point:** Before continuing, know how to [load a native\n| ad](/admob/android/native#load-ad). Learn more about native ads in our [Native Ads\n| Playbook](//admob.google.com/home/resources/native-ads-playbook/).\n\n\nUsing native ads you can customize your ads resulting in a better user\nexperience. Better user experiences can increase engagement and improve your\noverall yield.\n\nIn order to get the most out of native ads, it's important to style your ad\nlayouts so that they feel like a natural extension of your app. To help you get\nstarted, we've created Native Templates.\n\nNative Templates are code-complete views for your native ads, designed for fast\nimplementation and easy modification. With Native Templates, you can implement\nyour first native ad in just a few minutes, and you can quickly customize the\nlook and feel without a lot of code. You can place these templates anywhere you\nwant, such as in a recycler view used in a news feed, in a dialog, or anywhere\nelse in your app.\n| **Note:** If you're interested in designing your own native layouts from scratch, return to the [Native Advanced](/admob/android/native/advanced) documentation instead.\n\nOur native templates are provided as an Android Studio module, so it's easy to\ninclude them in your project and use them however you like.\n\nTemplate sizes\n\nThere are two templates: small and medium. They both use the `TemplateView`\nclass and both have a fixed aspect ratio. They will scale to fill the width of\ntheir parent views.\n\nSmall template \n\n @layout/gnt_small_template_view\n\nThe small template is ideal for recycler views, or any time you need a long\nrectangular ad view. For instance you could use it for in-feed ads.\n\nMedium template \n\n @layout/gnt_medium_template_view\n\nThe medium template is meant to be a one-half to three-quarter page view but\ncan also be used in feeds. It is good for landing pages or splash pages.\n\nFeel free to experiment with placement. Of course, you can also change the\nsource code and XML files to suit your requirements.\n\nInstalling the native ad templates\n\nTo install the native templates, simply [download the zip file (using the\n**Clone or download** option on\nGitHub)](//github.com/googleads/googleads-mobile-android-native-templates) and\nimport the module into your existing Android Studio project.\n\n1. Choose **File \\\u003e New \\\u003e Import Module**.\n\n2. Select the `nativetemplates` folder.\n\n3. Add the following line to your app-level `build.gradle` file:\n\n dependencies {\n ...\n implementation project(':nativetemplates')\n ...\n }\n\nUsing the native ad templates\n\nYou can use the template in any layout XML file, like any other view\ngroup.\n\nUsing the templates is a two-step process:\n\n1. First, you need to include the template as part of your layout.\n\n \u003cLinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n xmlns:tools=\"http://schemas.android.com/tools\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\"\n tools:context=\".MainActivity\"\n tools:showIn=\"@layout/activity_main\" \u003e\n\n \u003c!-- This is your template view --\u003e\n \u003ccom.google.android.ads.nativetemplates.TemplateView\n android:id=\"@+id/my_template\"\n \u003c!-- this attribute determines which template is used. The other option is\n @layout/gnt_medium_template_view --\u003e\n app:gnt_template_type=\"@layout/gnt_small_template_view\"\n android:layout_width=\"match_parent\"\n android:layout_height=\"match_parent\" /\u003e\n\n ...\n \u003c/LinearLayout\u003e\n\n2. Next, you need to give your template your native ad when it loads:\n\n MobileAds.initialize(this);\n AdLoader adLoader = new AdLoader.Builder(this, \"ca-app-pub-3940256099942544/2247696110\")\n .forNativeAd(new NativeAd.OnNativeAdLoadedListener() {\n @Override\n public void onNativeAdLoaded(NativeAd nativeAd) {\n NativeTemplateStyle styles = new\n NativeTemplateStyle.Builder().withMainBackgroundColor(background).build();\n TemplateView template = findViewById(R.id.my_template);\n template.setStyles(styles);\n template.setNativeAd(nativeAd);\n }\n })\n .build();\n\n adLoader.loadAd(new AdRequest.Builder().build());\n\nStyles dictionary keys\n\nThere are two ways to style your template: using traditional layout XML and\nusing our `NativeTemplateStyle.Builder` object. The above code sample\ndemonstrates how to use the `NativeTemplateStyle.Builder` object to set the main\nbackground color, but there are a variety of other options as well. Here are all\nof the available builder methods. The builder returns a `NativeTemplateStyle`\nobject which overrides any XML layout styling. The XML layouts\n`gnt_small_template.xml` and `gnt_medium_template.xml` use the same Android\nstyling parameters that you are already familiar with.\n\n| Builder methods for native template style ||\n|------------------------------------|----------------------------------------------------------------------------------------------|\n| `withCallToActionTextTypeface` | `Typeface callToActionTextTypeface` The typeface for the call to action. |\n| `withCallToActionTextSize` | `float callToActionTextSize` The size of the call to action text. |\n| `withCallToActionTypefaceColor` | `int callToActionTypefaceColor` The color of the call to action text. |\n| `withCallToActionBackgroundColor` | `ColorDrawable callToActionBackgroundColor` The background color of the call to action. |\n| `withPrimaryTextTypeface` | `Typeface primaryTextTypeface` The typeface of the first row of text. |\n| `withPrimaryTextSize` | `float primaryTextSize` The size of the first row of text. |\n| `withPrimaryTextTypefaceColor` | `int primaryTextTypefaceColor` The color of the first row of text. |\n| `withPrimaryTextBackgroundColor` | `ColorDrawable primaryTextBackgroundColor` The background color of the first row of text. |\n| `withSecondaryTextTypeface` | `Typeface secondaryTextTypeface` The typeface of the second row of text. |\n| `withSecondaryTextSize` | `float secondaryTextSize` The size of the second row of text. |\n| `withSecondaryTextTypefaceColor` | `int secondaryTextTypefaceColor` The text color of the second row of text. |\n| `withSecondaryTextBackgroundColor` | `ColorDrawable secondaryTextBackgroundColor` The background color of the second row of text. |\n| `withTertiaryTextTypeface` | `Typeface tertiaryTextTypeface` The typeface of the third row of text. |\n| `withTertiaryTextSize` | `float tertiaryTextSize` The size of the third row of text. |\n| `withTertiaryTextTypefaceColor` | `int tertiaryTextTypefaceColor` The text color of the third row of text. |\n| `withTertiaryTextBackgroundColor` | `ColorDrawable tertiaryTextBackgroundColor` The background color of the third row of text. |\n| `withMainBackgroundColor` | `ColorDrawable mainBackgroundColor` The main background color. |\n\nContribute\n\nWe've made Native Templates to help you develop native ads quickly.\nWe'd love to see you contribute to our\n[GitHub](//github.com/googleads/googleads-mobile-android-native-templates)\nrepo to add new templates or features. Send us a pull request and we'll take a\nlook."]]