android - 如何在 react-native 中组合多个内联样式对象和内联 css?

标签 android css react-native styles stylesheet

如何在react-native中组合多个内联样式对象和内联css?

它有 3 个样式对象 TimelineGreenColor、TimelineLeftBorder、TimelineLeftLine 用于 View div

  const stylesB = StyleSheet.create( {
     TimelineGreenColor:
     {
       backgroundColor: "green",
     },
     TimelineLeftBorder:
     {
       position: 'absolute',
       width: 4,
       backgroundColor: "green",
       height: '100%',
       left: 4,
       top: 15,
     },
     TimelineLeftCircle:
     {
       position: 'absolute',
       width: 12,
       height: 12,
       backgroundColor: "green",
       top: 12,
       borderRadius: 50,
       left: 0,
       /*boxShadow: "0px 0px 10px -2px black",*/
     },
     TimelineLeftLine:
     {
       position: 'absolute',
       width: 15,
       height: 3,
       backgroundColor: "green",
       top: 16,
       left: 5,
   }

   <View style={how to write styles in react-native ??????????}></View>

最佳答案

类型 1:如果您有一种内联样式

<View style = {{marginLeft: 7,paddingRight: "9%"}}></View>

类型 2:如果您有来自样式对象的一种样式

<View style = {styles.TimelineLeftBorder}></View>

类型 3:如果您有来自样式对象的两个或更多样式

<View style = {[styles.TimelineLeftBorder,styles.TimelineGreenColor]}></View>

类型 4:如果您有两个或更多来自样式对象的样式,并且您还想提供普通的内联 css

<View style = {[styles.TimelineLeftBorder,styles.TimelineGreenColor,{marginLeft: 7}]}></View>

关于android - 如何在 react-native 中组合多个内联样式对象和内联 css?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58449393/

相关文章:

react-native - 可能未处理的 Promise 拒绝 (id : 0): Error: Permission denied (while saving the image via "CameraRoll.saveToCameraRoll()"))

android - 通过 fragment 着色器将 YUV 转换为 RGB

android - 如何获取外部存储的路径?

java - 使用 Hilt 预填充房间数据库

html - 如何将这两个放在同一条线上? (一个居中,一个右对齐)

android - react native - 当初始项目 "undefined is not a function (evaluating ' reactDevTools.connectToDevTools') 时崩溃”

Android 应用索引 -> FirebaseAppIndexingInvalidArgumentException

css - 创建一个均分的数独板

javascript - vimeo 视频达到特定秒数时如何显示 div?

android - 如何在 React Native 中制作图像编辑器?