React Native自定义按钮样式问题

时间:2019-02-06 00:29:39

标签: react-native react-native-stylesheet

我正在设计通过TouchableOpacity响应本机的自定义按钮。到目前为止,我尝试了不同的样式设计方法,但并没有获得所需的设计。下面提到的是我要解决的尝试。

n

结果:

output Image

我想要这样设置我的本机按钮

enter image description here

2 个答案:

答案 0 :(得分:0)

使用以下样式并使用更多的渐变来设置与设计匹配的颜色并检查反映的变化

numericButton: {
  alignItems: 'center',
  margin: 10,
  padding: 10,
  backgroundColor: '#D3D3D3',
  borderColor: '#000',
  borderWidth: 2,
  //borderRadius:5,
  elevation: 5,
  shadowOffset: { width: 5, height: 5 },
  shadowColor: 'grey',
  shadowOpacity: 1,
  shadowRadius: 5,
},
numericButtonText: {
  fontSize: 24,
  fontWeight: 'bold',
  fontFamily: 'Cochin',
},

你很好!

答案 1 :(得分:0)

我们可以使用react-native-linear-gradient

实现相同类型的按钮

enter image description here

通过以下方式实现:

            <TouchableOpacity>
                <LinearGradient
                    // start={{x: 0.5, y: .5}} end={{x: 1, y: 1.0}}
                    style={styles.button}
                    locations={[0.3, 0, 0]}
                    colors={['#A8AFB5', 'white', 'white']}
                >
                     <Text style={styles.buttonText}>{props.data}</Text>
                </LinearGradient>
            </TouchableOpacity>




 const styles = StyleSheet.create({

    button: { flex: 1, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', borderRadius: 5, width: null, height: 81,marginTop:5, borderWidth: 1 },
    buttonText: {
        //textAlign:'center',
        fontSize: 24,
        fontWeight: 'bold',
        fontFamily: 'Cochin',
        color: 'black'
    }
});
相关问题