3

我在本机反应方面相对较新。

我可以像这里一样轻松地显示按钮(带有阴影等)。

 <Button
  mode="contained"
  color={'#f08e25'}
  contentStyle={{ height: 44 }}
  onPress={this.onPressSubmit}
  theme={theme} >SUBMIT </Button>

我也指的是这个文件。

https://callstack.github.io/react-native-paper/button.html#contentStyle

问题是如果模式为“包含”,我无法更改文本颜色。我尝试了 contentStyle 或主题,但它不起作用。如果模式为“包含”,我该如何更改文本颜色?

4

3 回答 3

6

对于 mode='contained' react-native-paper 按钮,颜色会改变背景颜色,你需要 labelStyle 来改变文本。对于 mode='flat' 按钮,颜色会改变文本。您只需要添加 labelStyle 道具。下面的代码将为您提供带有白色文本的橙色按钮,例如:

<Button
  mode="contained"
  color="#f08e25"
  contentStyle={{ height: 44 }}
  labelStyle={{ color: "white", fontSize: 18 }}
  onPress={this.onPressSubmit}
  theme={theme} >
    SUBMIT 
</Button>
于 2019-11-13T17:07:07.130 回答
3
import * as React from 'react';
import { Button,Text } from 'react-native-paper';

const MyComponent = () => (
  <Button icon="camera" color="blue" dark={true} compact={true}  style={{color:"red",marginTop:100}} mode="contained" onPress={() => console.log('Pressed')}>
   <Text style={{color:"red"}}>press me</Text>
  </Button>
);

export default MyComponent;

这是您在包含模式下的答案,颜色显示所有按钮的颜色,而不仅仅是文本

于 2019-10-23T05:14:37.230 回答
0
onPressSubmit = () => {
    setState({flag:true})
}
<Button
  mode="contained"
  color={'#f08e25'}
  contentStyle={this.state.flag ? styleA : styleB}
  onPress={this.onPressSubmit}
  theme={theme} >SUBMIT </Button>
于 2019-10-23T06:21:10.007 回答