简介
首页导航菜单,如图所示
示例
EasyNavigationBar navigationBar;
tabText、selectIcon、normalIcon、fragment 数量一定要一致
String[] tabText = {"首页", "消息", "工作室", "我的"};
//选中时icon
int[] selectIcon = {R.mipmap.tab1_s, R.mipmap.tab2_s, R.mipmap.tab1_s, R.mipmap.tab2_s};
//未选中icon
int[] normalIcon = {R.mipmap.tab1_n, R.mipmap.tab2_n, R.mipmap.tab1_n, R.mipmap.tab2_n};
List<Fragment> fragments = new ArrayList<>();
View dedtView = View.inflate(MainActivity.mainActivity, R.layout.tab_center, null);
navigationBar.titleItems(tabText)
.normalIconItems(normalIcon)
.selectIconItems(selectIcon)
.fragmentList(fragments)
.canScroll(false) //设置可否左右滑动
.normalTextColor(getResources().getColor(R.color.gray14)) //Tab未选中时字体颜色
.selectTextColor(getResources().getColor(R.color.mainColor)) //Tab选中时字体颜色
.addAsFragment(false)
.mode(0) //设置模式,自行改变调试哈
.mode(EasyNavigationBar.MODE_ADD_VIEW)
.addCustomView(dedtView) //中间按钮设置
.fragmentManager(getSupportFragmentManager())
.onAddClickListener(view -> {
return false;
})
.onTabClickListener((view, position) -> {
currentTabPosition = position;
return false;
})
.build();