三步實現(xiàn)底部導(dǎo)航欄
效果圖

效果圖
一.build里引入
//底部導(dǎo)航欄
api 'com.ashokvarma.android:bottom-navigation-bar:1.4.1'
二.xml布局文件插入
<!--底部的導(dǎo)航框-->
<com.ashokvarma.bottomnavigation.BottomNavigationBar
android:id="@+id/bottom_navigation_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:bnbBackgroundColor="@color/color_000000"
app:layout_constraintBottom_toBottomOf="parent"/>
三.代碼中放入
/**
* 初始化導(dǎo)航欄
*/
private void InitNavigationBar() {
mBottomNavigationBar.setTabSelectedListener(this);
mBottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED); //設(shè)置模式
//設(shè)置導(dǎo)航欄背景模式
mBottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
mBottomNavigationBar.setBackgroundColor(getResources().getColor(R.color.color_000000));
mBottomNavigationBar
.addItem(new BottomNavigationItem(R.drawable.home1, "首頁").setActiveColorResource(R.color.color_FEEC42))
.addItem(new BottomNavigationItem(R.drawable.information, "資訊").setActiveColorResource(R.color.color_FEEC42))
.addItem(new BottomNavigationItem(R.drawable.charts, "走勢圖").setActiveColorResource(R.color.color_FEEC42))
.addItem(new BottomNavigationItem(R.drawable.bet, "投注").setActiveColorResource(R.color.color_FEEC42))
.addItem(new BottomNavigationItem(R.drawable.other, "其它").setActiveColorResource(R.color.color_FEEC42))
.setFirstSelectedPosition(0)
.initialise();
setBottomNavigationItem(mBottomNavigationBar, 4, 26, 10);
}
ps:ok,完成了所以我們只需要引入,插入,放入就實現(xiàn)了底部導(dǎo)航欄_