Native Template Example

A minimal starter layout for a custom native template on Android, to use with Native Custom Layout.

It uses no Google Mobile Ads view classes. The media and ad-choices slots are plain FrameLayouts that the SDK fills, so leave them empty — anything already inside is removed.

Sizes and styling are deliberately plain. Replace them with your own. Labels in the schematic below are the view ids used in the layout.

┌──────────────────────────────────────────────┐
│ ad_label                          ad_choices │
│ ┌──────────┐  icon  headline                 │
│ │          │        body                     │
│ │  media   │                                 │
│ │          │        [ cta ]                  │
│ └──────────┘                                 │
└──────────────────────────────────────────────┘

res/layout/my_native_template.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="8dp">

    <!-- Required: label the placement as advertising. -->
    <TextView
        android:id="@+id/ad_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingHorizontal="3dp"
        android:text="Ad"
        android:textSize="10sp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <!-- Filled by the SDK with the ad's image or video. Leave empty. -->
    <FrameLayout
        android:id="@+id/media"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_marginTop="4dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/ad_label" />

    <!-- Filled by the SDK with the AdChoices overlay. Leave empty. -->
    <FrameLayout
        android:id="@+id/ad_choices"
        android:layout_width="15dp"
        android:layout_height="15dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <ImageView
        android:id="@+id/icon"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:layout_marginStart="8dp"
        android:contentDescription="@null"
        app:layout_constraintStart_toEndOf="@id/media"
        app:layout_constraintTop_toTopOf="@id/media" />

    <TextView
        android:id="@+id/headline"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginStart="8dp"
        android:maxLines="2"
        android:textSize="14sp"
        android:textStyle="bold"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@id/icon"
        app:layout_constraintTop_toTopOf="@id/media" />

    <TextView
        android:id="@+id/body"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:maxLines="2"
        android:textSize="12sp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="@id/headline"
        app:layout_constraintTop_toBottomOf="@id/headline" />

    <TextView
        android:id="@+id/cta"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:paddingHorizontal="8dp"
        android:paddingVertical="4dp"
        android:textSize="12sp"
        app:layout_constraintBottom_toBottomOf="@id/media"
        app:layout_constraintStart_toStartOf="@id/headline"
        app:layout_constraintTop_toBottomOf="@id/body" />

</androidx.constraintlayout.widget.ConstraintLayout>

Every view is optional. Show only the assets your design uses, and pass just those to FuseNativeAdBinding — a native ad may not carry every asset, so a template should tolerate any of them being absent.

advertiser, store and starRating are not shown above. Add views for them if your design needs them, and set the matching fields on the binding.