三步实现底部导航栏

三步实现底部导航栏

效果图

效果图

一.build里引入

//底部导航栏
api 'com.ashokvarma.android:bottom-navigation-bar:1.4.1'

二.xml布局文件插入

<!--底部的导航框-->
<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"/>

三.代码中放入

/**
 * 初始化导航栏
 */
private void InitNavigationBar() {
    mBottomNavigationBar.setTabSelectedListener(this);
    mBottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);   //设置模式
    //设置导航栏背景模式
    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,完成了所以我们只需要引入,插入,放入就实现了底部导航栏_

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。