使用recyclerView封装底部导航栏

作者: ccccccal | 来源:发表于2018-06-08 10:23 被阅读78次
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
  <com.alguojian.bottomlayout.BottomLayout
        android:id="@+id/bottomLayout"
        android:layout_width="match_parent"
        android:layout_height="50dp" />
  1. 添加资源文件
 BottomLayout bottomLayout = findViewById(R.id.bottomLayout);

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

        //选中时图片的背景,drawable-selected资源文件
        ArrayList<Integer> 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封装底部导航栏

本文链接:https://www.haomeiwen.com/subject/unmosftx.html