> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# updateViewport

APISummary
客户端更新 `LynxView` 视图大小。

## 语法

### Android

```java
public void updateViewport(int widthMeasureSpec, int heightMeasureSpec);
```

#### 参数说明

- `widthMeasureSpec`: 当前 `LynxView` 宽度。
- `heightMeasureSpec`: 当前 `LynxView` 高度。

### iOS

```objc
- (void)updateViewportWithPreferredLayoutWidth:(CGFloat)preferredLayoutWidth
                         preferredLayoutHeight:(CGFloat)preferredLayoutHeight
                                    needLayout:(BOOL)needLayout;
```

#### 参数说明

- `preferredLayoutWidth`: 当前 `LynxView` 宽度。
- `preferredLayoutHeight`: 当前 `LynxView` 高度。
- `needLayout`: 是否需要触发布局。

### Desktop (C++)

Desktop public API 使用 `SetFrame(...)` 更新视图矩形，屏幕指标则通过独立的 `UpdateScreenMetrics(...)` 暴露。

```cpp
void SetFrame(float x, float y, float width, float height);
```

#### 参数说明

- `x`: `LynxView` 的 x 坐标。
- `y`: `LynxView` 的 y 坐标。
- `width`: 当前 `LynxView` 的宽度。
- `height`: 当前 `LynxView` 的高度。

## 兼容性

**Compatibility Table**

**Query:** `lynx-native-api.lynx-view.update-viewport`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-native-api/lynx-view/update-viewport.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| update-viewport | Yes (2.1) | Yes (3.4) | Yes (2.1) | Yes (3.7) | Yes (3.7) | No |

**`update-viewport`**

update viewport of lynxView

**Specifications:**

