Native Ads Options

Native ads allow you to make additional customizations using the NativeAdOptions object. This guide shows you how to use NativeAdOptions.

Setting options


The last function included in the creation of the AdLoader above is another optional method, withNativeAdOptions():


.withNativeAdOptions(new NativeAdOptions.Builder()
    // Methods in the NativeAdOptions.Builder class can be
    // used here to specify individual options settings.


    // Methods in the NativeAdOptions.Builder class can be
    // used here to specify individual options settings.

The NativeAdOptions object allows apps to set specific options used in making the request. Its Builder class offers the following methods to use when creating an instance.


Image assets for native ads are returned via instances of NativeAd.Image, which holds a Drawable and a Uri. If this option is set to false (which is the default), the SDK fetches image assets automatically and populates both the Drawable and the Uri for you. If it's set to true, however, the SDK instead populates just the Uri field, allowing you to download the actual images at your discretion.


Some creatives have multiple available images to match different device orientations. Calling this method with one of the NativeAdOptions orientation constants (ORIENTATION_PORTRAIT, ORIENTATION_LANDSCAPE, ORIENTATION_ANY) requests images for a particular orientation. If this method is not called, the default value of ORIENTATION_LANDSCAPE is used.


Some image assets contain a series of images rather than just one. By setting this value to true, your app indicates that it's prepared to display all the images for any assets that have more than one. By setting it to false (default) your app instructs the SDK to provide just the first image for any assets that contain a series.

If withNativeAdOptions is not called at all when creating an AdLoader, the default value for each option is used.


The AdChoices overlay is set to the top right corner by default. Apps can change which corner this overlay is rendered in by setting this property to one of the following:


Apps can use this method to set options for video assets returned as part of a native ad. For more information, see the Native Video section of the native advanced guide.