I am new to React native so sorry if the question is dump.
我是新手,如果这个问题是垃圾的话,我很抱歉。
I would like to use the icon in material icons from https://mui.com/material-ui/material-icons/ in my material bottom nav bar from react navigation.
我想在我的材料底部导航栏中使用来自https://mui.com/material-ui/material-icons/的材料图标中的图标。
But the example given here https://reactnavigation.org/docs/material-bottom-tab-navigator/ is using material community icons. How can I change it to icons listed in https://mui.com/material-ui/material-icons/? Any help is appreciated. Many thanks.
但这里给出的例子https://reactnavigation.org/docs/material-bottom-tab-navigator/使用的是物质社区图标。如何将其更改为https://mui.com/material-ui/material-icons/?中列出的图标如有任何帮助,我们不胜感激。非常感谢。
import { StyleSheet, Text, View } from "react-native";
import { createMaterialBottomTabNavigator } from "@react-navigation/material-bottom-tabs";
import { NavigationContainer } from "@react-navigation/native";
import { MaterialCommunityIcons } from "@expo/vector-icons";
const Tab = createMaterialBottomTabNavigator();
function HomeScreen() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Home!</Text>
</View>
);
}
function SettingsScreen() {
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Text>Settings!</Text>
</View>
);
}
export default function App() {
return (
<NavigationContainer>
<Tab.Navigator>
<Tab.Screen
name="Trips"
component={HomeScreen}
// Here is the error
options={{
tabBarLabel: "Trips",
tabBarIcon: ({ color }) => <MaterialCommunityIcons name="travel-explore" color={color} size={26} />,
}}
/>
</Tab.Navigator>
</NavigationContainer>
);
}
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!