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

Expo LinearGradient iconExpo LinearGradient

渲染渐变视图的通用 React 组件。

Android
iOS
tvOS
Web
Included in Expo Go
Recommended version:
~58.0.3

expo-linear-gradient 提供一个原生的 React 视图,可以在多个颜色之间以线性方向进行过渡。

安装

🌐 Installation

Terminal
- npx expo install expo-linear-gradient
- yarn expo install expo-linear-gradient
- pnpm expo install expo-linear-gradient
- bun expo install expo-linear-gradient

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

用法

🌐 Usage

Linear Gradient
import { StyleSheet, Text, View } from 'react-native'; import { LinearGradient } from 'expo-linear-gradient'; export default function App() { return ( <View style={styles.container}> <LinearGradient // Background Linear Gradient colors={['rgba(0,0,0,0.8)', 'transparent']} style={styles.background} /> <LinearGradient // Button Linear Gradient colors={['#4c669f', '#3b5998', '#192f6a']} style={styles.button}> <Text style={styles.text}>Sign in with Facebook</Text> </LinearGradient> </View> ); } const styles = StyleSheet.create({ container: { flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: 'orange', }, background: { position: 'absolute', left: 0, right: 0, top: 0, height: 300, }, button: { padding: 15, alignItems: 'center', borderRadius: 5, }, text: { backgroundColor: 'transparent', fontSize: 15, color: '#fff', }, });

应用接口

🌐 API

import { LinearGradient } from 'expo-linear-gradient';

No API data file found, sorry!