【问题标题】:Expo can't change background color of container世博会无法改变容器的背景颜色
【发布时间】:2023-01-03 18:05:09
【问题描述】:

如您所见,我尝试使用样式更改背景颜色、强制使用灯光模式以及更改 app.json 中的背景颜色,但都没有效果。当我检查 expo 应用程序中的背景时,它说背景颜色是白色,但显然不是。

应用程序.js

import { StatusBar } from 'expo-status-bar';
import { StyleSheet, Text, View } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
});

应用程序.json

{
  "expo": {
    "name": "myProject",
    "slug": "myProject",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": [
      "**/*"
    ],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      }
    },
    "web": {
      "favicon": "./assets/favicon.png"
    }
  }
}

在运行时告诉我背景颜色是白色但实际上不是:

【问题讨论】:

    标签: react-native expo background-color


    【解决方案1】:

    如果你使用 <Stack.Navigator ...

    <Stack.Navigator screenOptions={{ contentStyle:{backgroundColor: "white"} }}> ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-21
      • 2014-04-21
      • 2021-01-23
      • 2011-06-15
      • 2022-06-11
      • 1970-01-01
      • 2012-04-02
      相关资源
      最近更新 更多