使用recyclerView封装底部导航栏

使用recyclerView封装底部导航栏_第1张图片
image

项目地址:
https://github.com/ALguojian/BottomLayout

使用如下:

  1. Add it in your root build.gradle at the end of repositories:
maven { url 'https://jitpack.io' }
  1. Add the dependency
implementation 'com.github.ALguojian:BottomLayout:1.1'
  1. 添加xml
  
  1. 添加资源文件
 BottomLayout bottomLayout = findViewById(R.id.bottomLayout);

        ArrayList strings = new ArrayList<>();
        strings.add("首页");
        strings.add("推广");
        strings.add("个人中心");
        bottomLayout.setTexts(strings);

        //选中时图片的背景,drawable-selected资源文件
        ArrayList images = new ArrayList<>();
        images.add(R.drawable.weex_select_home_background_one);
        images.add(R.drawable.weex_select_home_background_two);
        images.add(R.drawable.weex_select_home_background_three);
        bottomLayout.setImages(images);

        //添加字体选中时以及未选中时字体颜色
        bottomLayout.setTextColor(R.color.colorAccent, R.color.colorPrimaryDark);

        /**
         * 设置字体大小,单位sp,默认是11sp
         */
        bottomLayout.setTextSize(14);

        //点击的回调
        bottomLayout.build(position -> System.out.println("=======点击了第" + position + "个"));

你可能感兴趣的:(使用recyclerView封装底部导航栏)