This documentation is available as Markdown for AI agents and LLMs. See the full Markdown index or append .md to any documentation URL.

图片

一个用于显示图片的 Jetpack Compose 图片组件。

Android
Included in Expo Go
Recommended version:
~58.0.15

Expo UI Image 封装了官方 Jetpack Compose 的 Image API,并显示打包的或远程的图片。可以用 size、width 或 fillMaxWidth 这样的修饰符设置大小,然后用 contentScale 来控制图片如何填充这些边界。

🌐 Expo UI Image wraps the official Jetpack Compose Image API and displays a bundled or remote image. Set the size with modifiers such as size, width, or fillMaxWidth, then contentScale to control how the image fills those bounds.

Images rendered with different contentScale propsImages rendered with different contentScale props

安装

🌐 Installation

Terminal
- npx expo install @expo/ui
- yarn expo install @expo/ui
- pnpm expo install @expo/ui
- bun expo install @expo/ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

用法

🌐 Usage

ImageExample.tsx
import { Host, Image } from '@expo/ui/jetpack-compose'; import { size } from '@expo/ui/jetpack-compose/modifiers'; export default function ImageExample() { return ( <Host matchContents> <Image source={require('./assets/photo.jpg')} contentScale="crop" contentDescription="A mountain at sunset" modifiers={[size(240, 160)]} /> </Host> ); }

应用接口

🌐 API

import { Image } from '@expo/ui/jetpack-compose';

No API data file found, sorry!