react-native - 如何在 React-native 中制作线性渐变背景
解决方案
您可以使用 LinearGradient 代替 View 并将您的内容放在那里。
<LinearGradient
colors={['#373B44', '#4286f4', '#373B44']}
style={{
flex: 1,
}}
>
<Text>
Test
</Text>
</LinearGradient>
但您也可以使用 View 作为 LinearGradient 中的内容。
<LinearGradient
colors={['#373B44', '#4286f4', '#373B44']}
style={{
flex: 1,
}}
>
<View
style={{
margin: 20,
}}
>
<Text>
Test
</Text>
</View>
</LinearGradient>
我还通过源代码解释了react-native-linear-gradient 的用法及其功能。
推荐阅读
- android - 运行调用 ADB 命令的 Python 脚本以在 Jenkins 中运行 UI 测试
- c# - UWP:第一次加载时的 Listview 显示灰色背景不到一秒钟,然后在实际内容之前消失
- java - 如何仅使用 SAF 或不使用 SAF 打开 Google Drive?
- html - 将不带标签的 100% 宽度的复选框向左对齐
- google-api - 无法在 KML 弹出窗口中显示 GoogleAPI 图表
- r - 如何在 glm (R) 中拟合斜率修改器
- javascript - Javascript - 如何将功能点击从一个菜单传递到另一个菜单
- python - 动态气流 EMR 连接
- flask - SQLAlchemy 在 for 循环中添加/更新:更新不起作用
- javascript - Javascript 或 jQuery 中具有多个步骤和不同 url 的后退按钮