React native 反应本机flex和布局问题
我以前从未参与过应用程序开发项目,但由于我们没有人进行一些更改,我的经理希望我进行这些调整,到目前为止,我在stock overflow社区的帮助下取得了成功,但即使在网上搜索和观看YouTube视频时,我也无法掌握一些概念和代码 1-有时会为视图或文本指定预定义样式。exp:style={style.myAndroidStyle} 问题:我如何保持这种风格,并只收取一个参数,例如颜色 我把所有我尝试过的选项都用黑体字写了出来 2-说到颜色,这两种分配颜色的方法有什么区别 颜色={Colors.myColorGold} 颜色:Colors.myColorGold 3-同样的,这两种导航方式有什么不同 this.props.navigation.navigate('NotificationPreferences'); 这个。导航('NotificationPreferences') 4-我有一个带占位符的选择器,我尝试了所有方法来改变占位符的颜色,但没有成功,有什么想法吗React native 反应本机flex和布局问题,react-native,android-studio,styles,jsx,picker,React Native,Android Studio,Styles,Jsx,Picker,我以前从未参与过应用程序开发项目,但由于我们没有人进行一些更改,我的经理希望我进行这些调整,到目前为止,我在stock overflow社区的帮助下取得了成功,但即使在网上搜索和观看YouTube视频时,我也无法掌握一些概念和代码 1-有时会为视图或文本指定预定义样式。exp:style={style.myAndroidStyle} 问题:我如何保持这种风格,并只收取一个参数,例如颜色 我把所有我尝试过的选项都用黑体字写了出来 2-说到颜色,这两种分配颜色的方法有什么区别 颜色={Colors.
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**
}
constmypicker=({myOptions,handleChange,selectedID})=>{
return Platform.OS===“ios”(
) : (
{
ItemOptions.map((项目)=>(
))
}
)
}
ItemPicker.propTypes={
ItemOptions:PropTypes.object,
handleChangeItem:PropTypes.func,
selectedItemID:PropTypes.number,
**颜色:颜色。金色**,
**占位符文本颜色: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-我不认为选择器有任何类型的占位符,但它只有文本,您可以如下更改文本颜色
itemStyle={{ backgroundColor: "grey", color: "blue", fontFamily:"Ebrima", fontSize:17 }}
这些问题似乎很简单。你可以从官方文件中找到答案
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-我不认为选择器有任何类型的占位符,但它只有文本,您可以如下更改文本颜色
itemStyle={{ backgroundColor: "grey", color: "blue", fontFamily:"Ebrima", fontSize:17 }}
style={style.myAndroidStyle,{color:'black}}///您可以组合两种样式的地方最终不起作用,但我不得不使用这种格式style={[style.myAndroidStyle,{color:'black}}
style={style.myAndroidStyle,{color:'black}}//你可以将两种样式结合起来的地方最终不起作用,但我不得不使用这种格式来代替style={[style.myAndroidStyle,{color:'black}}