> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kontext.so/llms.txt
> Use this file to discover all available pages before exploring further.

# 让广告避开你的控件

> 叠加条幅位于容器的底部或顶部，暂停卡片位于顶部；SDK 让两者都避开与容器重叠的系统栏和屏幕刘海。

叠加条幅位于容器的底部或顶部，暂停卡片位于顶部；SDK 让两者都避开与容器重叠的系统栏和屏幕刘海。如果你的播放器在那里绘制自己的控件（标题、进度条、按钮），把它们占用的空间作为 `insets` 传入：

```kotlin theme={null}
// 你的控制栏高 controlBar.height 像素，位于播放器底部。
try {
    overlayAd?.show(playerContainer, Insets.of(0, 0, 0, controlBar.height))
} catch (e: VideoAdException) {
    // 未展示：已过期、屏幕上有其他广告、容器太小……
}
```

* `Insets` 是 `androidx.core.graphics.Insets`，单位为像素。它们叠加在系统栏和刘海之上：从它们的边缘量起，而不是从屏幕边缘。
* 广告展示期间它们保持不变，经过改变大小和旋转也是如此。广告在屏幕上时你的控件改变了大小，广告仍保留展示时的 insets。
* 广告仍须能以一半或更大的尺寸放下。insets 和容器的 padding 会占用空间，所以 `ContainerTooSmall` 包含它们。
* 全屏暂停广告忽略它们：它填满容器，它自己的控件会避开边缘。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.