[英]React native MaterialCommunityIcons not working in Top Tab Navigator Version 5
The Top tab navigation work but Icons are not showing only the name of the screen is showing here I am using react-navigation Version 5, if not materialcommunityicons other alternatives which can be used in top bar navigation and how to use that.顶部选项卡导航有效,但图标不显示仅屏幕名称显示在这里我使用 react-navigation 版本 5,如果不是 materialcommunityicons 其他可用于顶部栏导航的替代方案以及如何使用它。
import React from 'react';
import {Text, View} from 'react-native';
import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs';
import {MaterialCommunityIcons} from 'react-native-vector-icons/MaterialCommunityIcons'
const tab = createMaterialTopTabNavigator();
function DetailsScreen() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Details</Text>
</View>
);
}
function SettingScreen() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Syllabus!</Text>
</View>
);
}
function ProfileScreen() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Awards!</Text>
</View>
);
}
const Mytabs = () =>{
return(
<tab.Navigator initialRouteName="home">
<tab.Screen options={{
tabBarLabel: 'Home',
tabBarIcon: () => (
<MaterialCommunityIcons name="home" />
),
}}name="Home" component={DetailsScreen} />
<tab.Screen name="Settings" component={SettingScreen} />
<tab.Screen name="Profile" component={ProfileScreen} />
</tab.Navigator>
);
}
export default Mytabs;
first install and then please run this command:首先安装,然后请运行以下命令:
react-native link react-native-vector-icons
Open android/app/build.gradle and add the following:打开 android/app/build.gradle 并添加以下内容:
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.