kotlin

Native Video Ad Sample xml file

This XML file provides an example of how a native video ad can be created and encoded in XML. It includes the necessary parameters and elements needed to successfully encode a native video ad, allowing developers and advertisers to quickly and effectively create their own native video ad.

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.gms.ads.nativead.NativeAdView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:id="@+id/tv_video_tile_native_ad_attribution_small"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="#F19938"
            android:text="Ad"
            android:textColor="#FFFFFF"
            android:textSize="12sp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.google.android.gms.ads.nativead.MediaView
                android:id="@+id/native_ad_media"
                android:layout_width="match_parent"
                android:layout_margin="16dp"
                android:layout_height="200dp">
            </com.google.android.gms.ads.nativead.MediaView>

            <LinearLayout
                android:layout_width="match_parent"
                android:orientation="horizontal"
                android:paddingLeft="16dp"
                android:paddingRight="16dp"
                android:layout_height="60dp">
                <ImageView
                    android:id="@+id/native_ad_icon"
                    android:layout_width="60dp"
                    android:layout_height="60dp"></ImageView>

                <LinearLayout
                    android:orientation="vertical"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">
                    <TextView
                        android:id="@+id/native_ad_headline"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:lines="1"
                        android:maxLines="1"
                        android:textColor="#000000"
                        android:textSize="16sp"
                        tools:text="Headline" />

                    <TextView
                        android:id="@+id/native_ad_body"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:ellipsize="end"
                        android:lines="1"
                        android:maxLines="1"
                        android:textColor="#828282"
                        android:textSize="14sp"
                        tools:text="body" />
                </LinearLayout>
            </LinearLayout>
        </LinearLayout>

    </FrameLayout>
</com.google.android.gms.ads.nativead.NativeAdView>
Was this helpful?