1.首先导入依赖:compile ‘com.hjm:BottomTabBar:1.1.2’
然后定义xml文件:
<com.hjm.bottomtabbar.BottomTabBar
android:id= “@+id/navigation_bar”
android:layout_width= “match_parent”
android:layout_height= “match_parent”/>
你要是想进行一些属性设置的话,需要加上命名空间
xmlns:hjm=“http://schemas.android.com/apk/res-auto”
2. Activity文件代码:
private BottomTabBar navigation_bar;
navigation_bar= findViewById(R.id.navigation_bar);
然后建立四个fragment,这里我简单命名为:AFr,BFr,CFr,DFr
navigation_bar.init(getSupportFragmentManager())
.setFontSize(8)
.setImgSize(50,50)
.setTabPadding(4,6,10)
.setChangeColor(Color.RED,Color.GRAY)
.addTabItem("首页",R.drawable.home, AFr.class)
.addTabItem("发现",R.drawable.discover, BFr.class)
.addTabItem("趣事",R.drawable.funfacts, CFr.class)
.addTabItem("我的",R.drawable.ismy, DFr.class)
.isShowDivider(false);