با استفاده از تبلیغات بومی می توانید تبلیغات خود را سفارشی کنید و در نتیجه تجربه کاربری بهتری داشته باشید. تجربیات بهتر کاربر می تواند تعامل را افزایش دهد و بازده کلی شما را بهبود بخشد.
برای اینکه بیشترین بهره را از تبلیغات بومی ببرید، بسیار مهم است که به طرحبندی تبلیغات خود سبک دهید تا شبیه یک پسوند طبیعی برنامه شما باشد. برای کمک به شما برای شروع، ما الگوهای بومی ایجاد کرده ایم.
الگوهای بومی نماهایی با کد کامل برای تبلیغات بومی شما هستند که برای پیاده سازی سریع و اصلاح آسان طراحی شده اند. با الگوهای Native، می توانید اولین تبلیغ بومی خود را تنها در چند دقیقه پیاده سازی کنید و می توانید به سرعت ظاهر و احساس را بدون کد زیاد سفارشی کنید. میتوانید این الگوها را در هر جایی که میخواهید قرار دهید، مثلاً در نمای بازیافتی که در فید خبری، در گفتگو یا هر جای دیگری در برنامهتان استفاده میشود.
قالبهای بومی ما بهعنوان یک ماژول Android Studio ارائه میشوند، بنابراین به راحتی میتوانید آنها را در پروژه خود قرار دهید و هر طور که دوست دارید از آنها استفاده کنید.
اندازه های قالب
دو قالب وجود دارد: کوچک و متوسط. هر دو از کلاس TemplateView استفاده می کنند و هر دو دارای نسبت تصویر ثابت هستند. آنها برای پر کردن عرض نماهای والدین خود مقیاس خواهند شد.
قالب کوچک
@layout/gnt_small_template_view
قالب کوچک برای نماهای بازیافت کننده یا هر زمانی که به یک نمای تبلیغاتی مستطیلی طولانی نیاز دارید ایده آل است. به عنوان مثال می توانید از آن برای تبلیغات درون فید استفاده کنید.
قالب متوسط
@layout/gnt_medium_template_view
قالب متوسط برای نمایش یک و نیم تا سه چهارم صفحه طراحی شده است اما می تواند در فیدها نیز استفاده شود. برای صفحات فرود یا صفحات اسپلش خوب است.
احساس رایگان برای آزمایش با قرار دادن. البته، شما همچنین می توانید کد منبع و فایل های XML را مطابق با نیاز خود تغییر دهید.
دو راه برای استایل دادن به الگو وجود دارد: استفاده از طرح بندی سنتی XML و استفاده از شی NativeTemplateStyle.Builder ما. نمونه کد بالا نحوه استفاده از شی NativeTemplateStyle.Builder را برای تنظیم رنگ پس زمینه اصلی نشان می دهد، اما گزینه های متنوع دیگری نیز وجود دارد. در اینجا تمام روش های سازنده موجود است. سازنده یک شی NativeTemplateStyle را برمیگرداند که هر سبک طرحبندی XML را لغو میکند. طرحبندیهای 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
فونت ردیف اول متن.
withPrimaryTextSize
float primaryTextSize
اندازه ردیف اول متن.
withPrimaryTextTypefaceColor
int primaryTextTypefaceColor
رنگ ردیف اول متن.
withPrimaryTextBackgroundColor
ColorDrawable primaryTextBackgroundColor
رنگ پس زمینه ردیف اول متن.
withSecondaryTextTypeface
Typeface secondaryTextTypeface
فونت ردیف دوم متن.
withSecondaryTextSize
float secondaryTextSize
اندازه ردیف دوم متن.
withSecondaryTextTypefaceColor
int secondaryTextTypefaceColor
رنگ متن ردیف دوم متن.
withSecondaryTextBackgroundColor
ColorDrawable secondaryTextBackgroundColor
رنگ پس زمینه ردیف دوم متن.
withTertiaryTextTypeface
Typeface tertiaryTextTypeface
فونت ردیف سوم متن.
withTertiaryTextSize
float tertiaryTextSize
اندازه ردیف سوم متن.
withTertiaryTextTypefaceColor
int tertiaryTextTypefaceColor
رنگ متن ردیف سوم متن.
withTertiaryTextBackgroundColor
ColorDrawable tertiaryTextBackgroundColor
رنگ پس زمینه ردیف سوم متن.
withMainBackgroundColor
ColorDrawable mainBackgroundColor
رنگ پس زمینه اصلی
مشارکت کنید
ما الگوهای بومی ساختهایم تا به شما در توسعه سریع تبلیغات بومی کمک کنیم. مایلیم ببینیم که در مخزن GitHub ما برای افزودن قالبها یا ویژگیهای جدید مشارکت کنید. یک درخواست کشش برای ما ارسال کنید و ما بررسی می کنیم.
تاریخ آخرین بهروزرسانی 2025-09-06 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","easyToUnderstand","thumb-up"],["مشکلم را برطرف کرد","solvedMyProblem","thumb-up"],["غیره","otherUp","thumb-up"]],[["اطلاعاتی که نیاز دارم وجود ندارد","missingTheInformationINeed","thumb-down"],["بیشازحد پیچیده/ مراحل بسیار زیاد","tooComplicatedTooManySteps","thumb-down"],["قدیمی","outOfDate","thumb-down"],["مشکل ترجمه","translationIssue","thumb-down"],["مشکل کد / نمونهها","samplesCodeIssue","thumb-down"],["غیره","otherDown","thumb-down"]],["تاریخ آخرین بهروزرسانی 2025-09-06 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eNative Templates offer pre-built ad views for faster implementation and easier customization of native ads, leading to a better user experience and potentially higher ad revenue.\u003c/p\u003e\n"],["\u003cp\u003eThese templates come in two sizes (small and medium), suitable for various placements within your app, such as in feeds or as standalone elements.\u003c/p\u003e\n"],["\u003cp\u003eYou can easily integrate Native Templates by importing the provided module into your Android Studio project and adding a dependency in your build.gradle file.\u003c/p\u003e\n"],["\u003cp\u003eStyling options include using the NativeTemplateStyle.Builder object or modifying the XML layouts directly to match your app's design.\u003c/p\u003e\n"],["\u003cp\u003eContributions to the Native Templates project are welcomed through pull requests on the GitHub repository.\u003c/p\u003e\n"]]],["Native Templates provide pre-built views for native ads, allowing for quick implementation and customization. Download the templates from GitHub and import the module into your Android Studio project. There are small and medium template sizes, both using the `TemplateView` class. To use, include the template in your layout XML and provide the native ad data using the `NativeTemplateStyle.Builder` to customize styling options such as colors and text. Contributions to the GitHub repository are welcomed.\n"],null,["Select platform: [Android](/ad-manager/mobile-ads-sdk/android/native/templates \"View this page for the Android platform docs.\") [iOS](/ad-manager/mobile-ads-sdk/ios/native/templates \"View this page for the iOS platform docs.\") [Flutter](/ad-manager/mobile-ads-sdk/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](/ad-manager/mobile-ads-sdk/android/native#load-ad).\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](/ad-manager/mobile-ads-sdk/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, \"/21775744923/example/native\")\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 AdManagerAdRequest.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."]]