当前位置:首页 > 安卓源码 > 控件分类 > 菜单Menu >

Android BottomBar封装底部TAB导航栏,支持显示红点和数字提醒

时间:2017-02-08 09:11 来源:互联网 作者:源码搜藏收藏

  • 源码类别:菜单Menu
  • 源码大小:未知
  • 编码格式:gbk,utf8,不限
  • 运行环境:Android studio
  • 广告推荐

BottomBarLayout

使用:

XML:

    <com.example.liuhao.bottombar.BottomBarLayout
        android:id="@+id/bottom_nav"
        android:layout_width="match_parent"
        android:layout_height="48dp"
        android:background="#FFFFFF"
        android:layout_alignParentBottom="true"/>

Activity:

init:

private BottomBarLayout bottomBarLayout;
private List<TabEntity> tabEntityList;
private String[] tabText = {"tab0","tab1","tab2","tab3"};

private int[] normalIcon = {R.mipmap.home,R.mipmap.play,R.mipmap.buy,R.mipmap.mine};
private int[] selectIcon = {R.mipmap.home1,R.mipmap.play1,R.mipmap.buy1,R.mipmap.mine1};
private int normalTextColor = Color.parseColor("#999999");

private int selectTextColor = Color.parseColor("#fa6e51");
bottomBarLayout = (BottomBarLayout) findViewById(R.id.bottom_nav);
tabEntityList = new ArrayList<>();
    for (int i=0;i<tabText.length;i++){
         TabEntity item = new TabEntity();
         item.setText(tabText[i]);
         item.setNormalIconId(normalIcon[i]);
         item.setSelectIconId(selectIcon[i]);
         tabEntityList.add(item);
   }

设置默认颜色和选中颜色:

bottomBarLayout.setNormalTextColor(normalTextColor); 
bottomBarLayout.setSelectTextColor(selectTextColor);

设置tab数据:

bottomBarLayout.setTabList(tabEntityList);

点击监听:

 bottomBarLayout.setOnItemClickListener(new BottomBarLayout.OnItemClickListener() {
            @Override
            public void onItemClick(int position) {
                Toast.makeText(MainActivity.this,position+"",Toast.LENGTH_SHORT).show();
            }
  });
本站资源仅限于学习研究,严禁从事商业或者非法活动! 源码搜藏网所有源码来自互联网转载与用户上传分享,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!

菜单Menu下载排行

最新文章