[Native style settings](https://support.google.com/admanager/answer/9414028#native-ad-settings-and-styles)
let Google Ad Manager handle the rendering of your native ads based on
native styles you specify within the product. First, specify size and targeting.
Then add HTML, CSS, and JavaScript to define ads that are responsive
and produce a quality display across all screens. You don't need to do
any of the rendering; Ad Manager automatically applies the right native style
for the destination. Native styles are implemented just like banner ads. They
are rendered with a fluid ad size determined at runtime, or with a fixed
ad size determined ahead of time.

## Prerequisites

- Complete the [Get started guide](https://developers.google.com/ad-manager/mobile-ads-sdk/android/next-gen/quick-start.md.txt).

## Fluid size

You can use the Fluid ad size in the Ad Manager UI to achieve an ad that
dynamically adjusts to fit its content. With this setting, the ad's width will
match your app's content, and its height will adjust at runtime to accommodate
the ad's content. The SDK provides a special `AdSize` constant,
[`FLUID`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/AdSize#FLUID()), to handle this case. The fluid ad size
height is dynamically determined based on the publisher defined width, allowing
the ad view to adjust its height to match that of the creative.

### Create a fluid ad request

Create a layout container for the ad view. Set the `layout_height` of the ad
container to `wrap_content` because its height will be determined by the ad
returned at runtime.

```xml
<FrameLayout
   android:id="@+id/fluid_ad_container"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:layout_gravity="center_horizontal" />
```

Here's what the implementation looks like for making the ad request:

### Kotlin

```kotlin
// Be sure to specify Fluid as the ad size in the Ad Manager UI and create
// an ad request with FLUID size.
val adRequest = BannerAdRequest.Builder("AD_UNIT_ID", AdSize.FLUID).build()
```

### Java

```java
// Be sure to specify Fluid as the ad size in the Ad Manager UI and create
// an ad request with FLUID size.
BannerAdRequest adRequest = new BannerAdRequest.Builder("AD_UNIT_ID", AdSize.FLUID).build();
```

Replace <var translate="no">AD_UNIT_ID</var> with your test device ID.

Once you successfully load the ad, add [`BannerAd.getView()`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/banner/BannerAd.md.txt#getView(android.app.Activity))
to the view hierarchy. For more details, see [Load an ad](https://developers.google.com/ad-manager/mobile-ads-sdk/android/next-gen/banner.md.txt#load_an_ad).

## Fixed size

Native styles with a fixed size let you control the width and height
of the native ad.

To set a fixed size, follow these steps:

Set an ad size smaller than or equal to the device screen size.
To determine the maximum screen size, use the
[`Resources.getDisplayMetrics`](https://developer.android.com/reference/android/content/res/Resources#getDisplayMetrics())
method. The `AdSize` object dimensions use density-independent pixels (dp). When comparing, convert the
screen size from pixels to dp.
For details about size constraints, see
[Troubleshoot unfilled impressions in Ad Manager](https://support.google.com/admanager/answer/1739296).


1. Create a line item in the Ad Manager UI and select one of the
   predefined sizes from the `Size` field drop-down.

2. Load a [`BannerAd`](https://developers.google.com/ad-manager/mobile-ads-sdk/android/next-gen/reference/com/google/android/libraries/ads/mobile/sdk/banner/BannerAd.md.txt) ad with the predefined `AdSize`.