Page Summary
-
This guide details advanced features for customizing native ads on Android, including asset controls, AdChoices placement, video controls, and custom click gestures.
-
You can specify a preferred aspect ratio for media assets, control image download behavior, and request multiple images for assets that contain a series.
-
AdChoices placement can be set to one of four corners or rendered within a custom view, with custom view access being limited.
-
Video ad playback can be customized by setting the initial mute state and implementing custom playback controls, although custom controls access is limited.
-
Custom click gestures, which allow swipes to be registered as clicks, are disabled by default and access is limited.
Native ads have many advanced features that allow you to make additional customizations and make the best possible ad experience. This guide shows you how to use the advanced features of native ads.
Prerequisites
- Integrate the Native ad format .
Asset controls
This section details how to customize the creative assets in your native ads. You have the option to specify a preferred aspect ratio for media assets and how the image assets are downloaded and displayed.
Preferred media aspect ratio controls
Media Aspect Ratio Controls let you specify a preference for the aspect ratio of ad creatives.
Call NativeAdOptions.Builder.setMediaAspectRatio()
with a NativeAdOptions.MediaAspectRatio
value.
-
When unset, the returned ad can have any media aspect ratio.
-
When set, you will be able to improve the user experience by specifying the preferred type of aspect ratio.
The following example instructs the SDK to prefer a return image or video with a specific aspect ratio.
Java
Kotlin
Replace AD_UNIT_ID with your ad unit ID.
Image download control
Image download control lets you decide if image assets or only URIs are returned by the SDK.
Call NativeAdOptions.Builder.setReturnUrlsForImageAssets()
with a boolean
value.
-
Image download control are disabled by default.
-
When disabled, Google Mobile Ads SDK populates both the image and the URI for you.
-
When enabled, the SDK instead populates just the URI, allowing you to download the actual images at your discretion.
The following example instructs the SDK to return just the URI.
Java
Kotlin
Image payload controls
Some ads have a series of images rather than just one. Use this feature to indicate whether your app is prepared to display all the images or just one.
Call NativeAdOptions.Builder.setRequestMultipleImages()
with a boolean
value.
-
Image payload controls are disabled by default.
-
When disabled, your app instructs the SDK to provide just the first image for any assets that contain a series.
-
When enabled, your app indicates that it is prepared to display all the images for any assets that have more than one.
The following example instructs the SDK to return multiple image assets.
Java
Kotlin
AdChoices placements
This section details how to position the AdChoices overlay. You have the option to set its placement to one of the four corners or render it within a custom view.
AdChoices position controls
The AdChoices position controls lets you choose which corner to render the AdChoices icon.
Call NativeAdOptions.Builder.setAdChoicesPlacement()
with a NativeAdOption.AdChoicesPlacement
value.
-
If unset, the AdChoices icon position is set to the top right.
-
If set, AdChoices is placed at the custom position as requested.
The following example demonstrates how to set a custom AdChoices image position.
Java
Kotlin
AdChoices custom view
The AdChoices custom view feature lets you position the AdChoices icon in a custom location. This is different from AdChoices position controls, which only allows specification of one of the four corners.
Call NativeAdView.setAdChoicesView()
with a AdChoicesView
value.
The following example demonstrates how to set a custom AdChoices view, with the
AdChoices icon rendered inside the AdChoicesView
.
Java
NativeAdView
nativeAdView
=
new
NativeAdView
(
context
);
AdChoicesView
adChoicesView
=
new
AdChoicesView
(
context
);
nativeAdView
.
setAdChoicesView
(
adChoicesView
);
Kotlin
val
nativeAdView
=
NativeAdView
(
context
)
val
adChoicesView
=
AdChoicesView
(
context
)
nativeAdView
.
adChoicesView
=
adChoicesView
.
kt

