React Native flex and Layout issue



我以前从未参与过应用程序开发项目,但由于我们没有人可以进行一些更改,我的经理希望我进行这些调整,到目前为止,我在股票溢出社区的帮助下取得了成功,但很少有概念和代码行是我在网上搜索和观看YouTube视频时无法掌握的。

1-有时会为视图或文本指定预定义的样式。exp:style={styles.myAndroidStyle}问题:例如,我如何保持这种风格并只对一个参数收费?

我把我尝试过的所有选项都用粗体写了出来。

2-说到颜色,这两种颜色分配方式有什么区别color={Colors.myColorGold}颜色:Colors.myColorGold

3-同样的事情,这两种导航方式有什么区别this.props.navigation.anavigation("NotificationPreferences"(;this.navigation("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**
}

这些问题似乎很简单。你可能需要从官方文件中找到答案。

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=和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-我不认为pickers有任何类型的占位符,但它只有文本,你可以按如下方式更改文本颜色。

itemStyle={{ backgroundColor: "grey", color: "blue", fontFamily:"Ebrima", fontSize:17 }}

最新更新