Android底部导航栏实现(一)之BottomNavigationBar
BottomNavigationBar这个控件的使用之前已经写过,这里不再赘述,详情请参考BottomNavigationBar的使用。
下面直接上代码:
初始化及相关设置:
mBottomNavigationBar = (BottomNavigationBar) view.findViewById(R.id.bottom_navigation_bar); mBottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC); mBottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED); mBottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.home_fill, getString(R.string.item_home)).setInactiveIconResource(R.drawable.home).setActiveColorResource(R.color.colorPrimary).setInActiveColorResource(R.color.black_1)) .addItem(new BottomNavigationItem(R.drawable.location_fill, getString(R.string.item_location)).setInactiveIconResource(R.drawable.location).setActiveColorResource(R.color.colorPrimary).setInActiveColorResource(R.color.black_1)) .addItem(new BottomNavigationItem(R.drawable.like_fill, getString(R.string.item_like)).setInactiveIconResource(R.drawable.like).setActiveColorResource(R.color.colorPrimary).setInActiveColorResource(R.color.black_1)) .addItem(new BottomNavigationItem(R.drawable.person_fill, getString(R.string.item_person)).setInactiveIconResource(R.drawable.person).setActiveColorResource(R.color.colorPrimary).setInActiveColorResource(R.color.black_1)) .setFirstSelectedPosition(0) .initialise(); mBottomNavigationBar.setTabSelectedListener(this); setDefaultFragment();
Tab的切换:
相关推荐
doomvsjing 2020-05-30
思捻如枫 2015-08-11
故作坚强 2015-02-15
刘炳昭 2018-07-10
Nostalgiachild 2018-07-10
Michael 2018-07-10
静博圣宇 2017-04-18
sapcefish 2016-12-07
Hens00 2016-12-07