0

我想更改所有按钮样式,而不必像这样一个接一个地添加样式:

<Button mode="contained" style={{ backgroundColor: "#FF6766" }} >

我正在尝试对此做些什么:

const theme = {
  ...DefaultTheme,
  roundness: 2,
  colors: {
    ...DefaultTheme.colors,
    primary: '#ffffff',
    accent: '#f1c40f',
    text: '#515151',
    surface: '#FF6766',
    underlineColor: 'transparent',
    background: '#ffffff',
    contained: '#000000',
  }
};

但我不知道这里是否可行,我在这个链接上找到了这个: https ://callstack.github.io/react-native-paper/theming.html

应用程序.js

export default function App() {

  const theme = {
    ...DefaultTheme,
    roundness: 2,
    colors: {
      ...DefaultTheme.colors,
      primary: '#ffffff',
      accent: '#f1c40f',
      text: '#515151',
      surface: '#FF6766',
      underlineColor: 'transparent',
      background: '#ffffff',
      contained: '#000000',
    }
  };

  return (
    <PaperProvider theme={theme}>
      <AppNavigator />
    </PaperProvider>
  )

}
4

0 回答 0