[英]React Native Paper Dark Theme
如何在 React Native Paper 中將主題設置為深色主題? 在我所有的屏幕中,所有<View>
仍然有白色背景。
const theme = {
...DarkTheme,
colors: {
...DarkTheme.colors,
primary: '#2d3436',
accent: '#1C1C1C',
background : '#636e72'
}
};
render() {
return(
<PaperProvider theme={theme}>
<App />
</PaperProvider>
);
}
應用主題和提供者級別不會更改所有視圖。 導出時您必須使用“withTheme”,這將提供可用於訪問 colors 的主題道具。
import { withTheme } from 'react-native-paper';
const Test = ({ theme,children }) => {
const { colors } = theme;
return (
<View style={{ backgroundColor: colors.background }}>
{children}
</View>
);
};
export default withTheme(Test);
如果您想為所有視圖使用相同的主題,請創建一個自定義包裝器組件,該組件設置顏色,如上
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.