我以前从未从事过应用程序开发项目,但是由于我们没有人可以做一些更改,因此我的经理希望我进行这些调整,到目前为止,我在股票溢出社区的帮助下取得了成功,但是甚至在网上搜索和观看YouTube视频时,我都无法掌握一些概念和代码行。
1-有时为视图或文本分配预定义的样式。 exp:style = {styles.myAndroidStyle} 问题:如何保持这种样式并仅收取一个参数(例如颜色)?
我将所有尝试的选项都加粗了。
2-说到颜色,这两种分配颜色的方式有什么区别 color = {Colors.myColorGold} 颜色:Colors.myColorGold
3-这里也是一样,这两种导航方式有什么区别 this.props.navigation.navigate('NotificationPreferences'); this.navigate('NotificationPreferences');
4-我有一个带占位符的选择器,我尝试了所有更改占位符颜色的操作,但没有成功,知道吗?
const MyPicker = ({myOptions, handleChange, selectedID}) => {
return Platform.OS === 'ios' ? (
<RNPickerSelect
placeholder={{label: 'Select an item', value: null, **placeholderTextColor: Colors.myColorGold**}}
**placeholderTextColor={Colors.myColorGold}**
items={itemOptions}
onValueChange={handleChangeItem}
style={{inputIOS: styles.inputIOS, inputAndroid: styles.inputAndroid, **Color: Colors.myColorGold**}}
value={selectedItemID}
**textColor={Colors.myColorGold}**
/>
) : (
<Picker
selectedValue={selectedItemID}
style={styles.inputAndroid}
onValueChange={handleChangeItem}
**textColor={Colors.myColorGold}**
**Color={Colors.myColorGold}**
>
<Picker.Item label="Select a item" value="null" **textColor={Colors.myColorGold} Color={Colors.myColorGold}**/>
{
ItemOptions.map((item) => (
<Picker.Item key={item.value} label={item.label} value={item.value} **textColor={Colors.myColorGold} Color={Colors.myColorGold}** />
))
}
</Picker>
)
}
ItemPicker.propTypes = {
ItemOptions: PropTypes.object,
handleChangeItem: PropTypes.func,
selectedItemID: PropTypes.number,
**Color: Colors.myColorGold**,
**placeholderTextColor: Colors.myColorGold**
}
答案 0 :(得分:0)
这些问题似乎很简单。您可能必须从官方文档中找到答案。
1- style={styles.myAndroidStyle}
//you can style your components as follows
1==> style={{color:'black'}}//for component having one style
2==> style={styles.myAndroidStyle}//where myAndroidStyle would have all the stylings
3==> style={[style.myAndroidStyle,{color:'black}]}//where you can combine both the stylings
2- color color={Colors.myColorGold} color: Colors.myColorGold
在这种情况下,我可能是错的,但实际上它看起来像是color = and color:是为Colore.myColorGold具有特定颜色的组件提供样式的方式。
3- this.props.navigation.navigate('NotificationPreferences');
实际上,这是导航到特定屏幕的正确方法。
this.navigate('NotificationPreferences');
//here it seems as navigate can be defined as follows:
const navigate=this.props.navigation.navigate;
or
navigate(screen)
{
return this.props.navigation.navigate(screen)}
4-我认为选择器没有任何占位符,而是仅包含文本,您可以按如下方式更改其文本颜色。
itemStyle={{ backgroundColor: "grey", color: "blue", fontFamily:"Ebrima", fontSize:17 }}