---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ads.yandex.com/helpcenter/en/dev/android7/template.md
  - https://ads.yandex.com/helpcenter/ru/dev/android7/template.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ads.yandex.com/helpcenter/ru/llms.txt

<!--
Используется в Boost: boost/ru/ad-monetization/dev/android
-->

# Настройка внешнего оформления с помощью шаблона

 

Для настройки внешнего оформления можно использовать стандартный шаблон оформления. Шаблон содержит набор предустановленных настроек для всех визуальных компонентов рекламы, но при этом их можно кастомизировать. 

{% cut "Пример кода" %}

   {% list tabs %}

   - Kotlin

     ```kotlin
     private fun showAd(nativeAd: NativeAd) {
         val bannerAppearance = createNativeBannerViewAppearance()
         binding.nativeBanner.applyAppearance(bannerAppearance)
         binding.nativeBanner.setAd(nativeAd)
     }

     private fun createNativeBannerViewAppearance(): NativeTemplateAppearance {
         return NativeTemplateAppearance.Builder()
             .withBannerAppearance(
                 BannerAppearance.Builder()
                     .setBorderColor(Color.YELLOW).build()
             )
             .withCallToActionAppearance(
                 ButtonAppearance.Builder()
                     .setTextAppearance(
                         TextAppearance.Builder()
                             .setTextColor(Color.BLUE)
                             .setTextSize(14f).build()
                     )
                     .setNormalColor(Color.TRANSPARENT)
                     .setPressedColor(Color.GRAY)
                     .setBorderColor(Color.BLUE)
                     .setBorderWidth(1f).build()
             )
             .withImageAppearance(
                 ImageAppearance.Builder()
                     .setWidthConstraint(
                         SizeConstraint(
                             SizeConstraint.SizeConstraintType.FIXED,
                             60f
                         )
                     ).build()
             )
             .withAgeAppearance(
                 TextAppearance.Builder()
                     .setTextColor(Color.GRAY)
                     .setTextSize(12f).build()
             )
             .withBodyAppearance(
                 TextAppearance.Builder()
                     .setTextColor(Color.GRAY)
                     .setTextSize(12f).build()
             )
             .withRatingAppearance(
                 RatingAppearance.Builder()
                     .setProgressStarColor(Color.CYAN).build()
             )
             .withTitleAppearance(
                 TextAppearance.Builder()
                     .setTextColor(Color.BLACK)
                     .setTextSize(14f).build()
             )
             .build()
     }
     ```
   - Java

     ```java
     private void showAd(@NonNull final NativeAd nativeAd) {
         final NativeTemplateAppearance bannerAppearance = createNativeBannerViewAppearance();
         mBinding.nativeBanner.applyAppearance(bannerAppearance);
         mBinding.nativeBanner.setAd(nativeAd);
     }

     private NativeTemplateAppearance createNativeBannerViewAppearance() {
         return new NativeTemplateAppearance.Builder()
                 .withBannerAppearance(
                         new BannerAppearance.Builder()
                                 .setBorderColor(Color.YELLOW).build()
                 )
                 .withCallToActionAppearance(
                         new ButtonAppearance.Builder()
                                 .setTextAppearance(
                                         new TextAppearance.Builder()
                                                 .setTextColor(Color.BLUE)
                                                 .setTextSize(14f).build()
                                 )
                                 .setNormalColor(Color.TRANSPARENT)
                                 .setPressedColor(Color.GRAY)
                                 .setBorderColor(Color.BLUE)
                                 .setBorderWidth(1f).build()
                 )
                 .withImageAppearance(
                         new ImageAppearance.Builder()
                                 .setWidthConstraint(
                                         new SizeConstraint(
                                                 SizeConstraint.SizeConstraintType.FIXED,
                                                 60f
                                         )
                                 ).build()
                 )
                 .withAgeAppearance(
                         new TextAppearance.Builder()
                                 .setTextColor(Color.GRAY)
                                 .setTextSize(12f).build()
                 )
                 .withBodyAppearance(
                         new TextAppearance.Builder()
                                 .setTextColor(Color.GRAY)
                                 .setTextSize(12f).build()
                 )
                 .withRatingAppearance(
                         new RatingAppearance.Builder()
                                 .setProgressStarColor(Color.CYAN).build()
                 )
                 .withTitleAppearance(
                         new TextAppearance.Builder()
                                 .setTextColor(Color.BLACK)
                                 .setTextSize(14f).build()
                 )
                 .build();
     }
     ```
   {% endlist %}
   
{% endcut %} 

{% note info %}

При создании своего оформления на основе шаблона необязательно задавать предпочитаемые настройки для всех визуальных компонентов. Компоненты, для которых не установлены предпочитаемые настройки, будут сконфигурированы значениями по умолчанию.

{% endnote %}
