反应原生的样式activityIndi​​cator

时间:2018-04-05 11:17:45

标签: react-native

我正在尝试设置color的{​​{1}}:

ActivityIndicator

我在这里设定我的风格:

 <View style={[{height: this.props.calendarHeight}, this.style.placeholder]}>
      <ActivityIndicator size="large" color={this.style.loadingSpinner.color} />
    </View>

我的 import React, {Component} from 'react'; import {Text, View, ActivityIndicator} from 'react-native'; import Calendar from '../calendar'; import styleConstructor from './style'; class CalendarListItem extends Component { constructor(props) { super(props); this.style = styleConstructor(props.theme); } shouldComponentUpdate(nextProps) { const r1 = this.props.item; const r2 = nextProps.item; return r1.toString('yyyy MM') !== r2.toString('yyyy MM') || !!(r2.propbump && r2.propbump !== r1.propbump); } render() { const row = this.props.item; if (row.getTime) { return ( <Calendar theme={this.props.theme} style={[{height: this.props.calendarHeight}, this.style.calendar]} current={row} hideArrows hideExtraDays={this.props.hideExtraDays === undefined ? true : this.props.hideExtraDays} disableMonthChange markedDates={this.props.markedDates} markingType={this.props.markingType} hideDayNames={this.props.hideDayNames} onDayPress={this.props.onDayPress} minDate={this.props.minDate} maxDate={this.props.maxDate} firstDay={this.props.firstDay} monthFormat={this.props.monthFormat} dayComponent={this.props.dayComponent} disabledByDefault={this.props.disabledByDefault} showWeekNumbers={this.props.showWeekNumbers} />); } else { const text = row.toString(); return ( <View style={[{height: this.props.calendarHeight}, this.style.placeholder]}> <ActivityIndicator size="large" color={this.style.loadingSpinner} /> </View> ); } } } export default CalendarListItem; 是:

style.js

但是,import {StyleSheet} from 'react-native'; import * as defaultStyle from '../style'; const STYLESHEET_ID = 'stylesheet.calendar-list.main'; export default function getStyle(theme={}) { const appStyle = {...defaultStyle, ...theme}; return StyleSheet.create({ container: { backgroundColor: appStyle.calendarBackground }, placeholder: { backgroundColor: appStyle.calendarBackground, alignItems: 'center', justifyContent: 'center' }, placeholderText: { fontSize: 30, fontWeight: '200', color: appStyle.dayTextColor }, loadingSpinner: { color: '#fff' }, calendar: { paddingLeft: 15, paddingRight: 15 }, ...(theme[STYLESHEET_ID] || {}) }); } 未定义。

如何设置颜色?

2 个答案:

答案 0 :(得分:1)

要设置ActivityIndi​​cator组件的颜色,只需将道具颜色设置为您想要的颜色,就像这样

<ActivityIndicator color={colors.yourColor} /> // if you have an object with your colors

<ActivityIndicator color='#000' /> 

您还可以使用道具尺寸

更改此组件的大小
<ActivityIndicator size='small' /> // you can set 'small' or 'large'

记得从&#39; react-native&#39;

导入ActivityIndi​​cator

答案 1 :(得分:0)

你可以给自定义样式做类似的事情 -

.map(df2.set_index('Company').Alias

//添加类似这样的样式 -

df1['Alias'] = df1.Company.apply(lambda x: [process.extract(x, aliases, limit=1)][0][0][0])