react-native - 如何在反应原生中添加框和文本之间的渐变
问题描述
在反应原生应用程序中,我想在框和文本之间添加渐变。
图片 :
预期图像:
编码 :
<View style={{backgroundGradientBottom: "#666666",width:Dimensions.get('window').width-30}}>
<Text numberOfLines={5} style={{fontSize: 20,marginBottom:15,marginTop:20,fontFamily:''}}>{firstParagraph}</Text>
<View style={ {justifyContent: 'center',alignItems: 'center', height: 300, borderWidth: 2,marginBottom:15 }}>
<Text style={{fontSize: 20,marginBottom:15}}>Weiterlesen mit Tageblatt-Premium</Text>
<Text style={{textAlign: "center",fontSize: 16,marginBottom:15,marginTop:20}}>Jetzt 24 Stunden kostenlos und unverbindlich testen</Text>
<View style = {{alignSelf: 'center',marginBottom:15,marginTop:20}} >
<Button style={{alignSelf: 'center',marginTop:10,backgroundColor: 'red',padding:15}} >
<Text style={{ color: 'white'}}>24 STUNDEN GRATIS-TEST</Text>
</Button>
</View>
<View
style={{
borderBottomColor: "black",
borderBottomWidth: 1,
alignSelf:'stretch',
marginHorizontal:15
}}
/>
<View style={{ marginHorizontal:15,alignSelf: 'flex-start',flexDirection: 'row'}}>
<Text style={{ fontSize: 14 }} >Bereits abonniert?</Text>
<Text style={{marginLeft:120,alignSelf: 'flex-end',fontSize: 14,textDecorationLine: 'underline' }} >Anmelden</Text>
</View>
</View>
</View>
解决方案
React Native 默认不支持渐变,需要你自己使用react-native-linear-gradient
。
https://github.com/react-native-community/react-native-linear-gradient
推荐阅读
- eiffel - 两个不同的配置文件共享相同的 UUID。在配置中
- android - 第一个元素在 GridView 适配器的列表末尾弹出
- pygame - 我想在我的飞鸟游戏中添加一个炸弹,但它不会检测到碰撞。这是代码
- r - 根据其他列值替换 For 循环以填充列
- python - Pyspark从现有数组列创建一定长度的数组列
- google-chrome - 在 url 更改时重新加载内容脚本
- flutter - Flutter Gradle 构建时出现错误异常
- node.js - 优雅启动 Node.js 网络服务器应用程序的好方法是什么
- c - 在 c 中解析 argc 和 argv[] 参数
- reactjs - 了解应用程序中的事件驱动架构和状态管理