Tablayout变颜色 以及Fragment进行切换

 

                                  第一步

        在Xml 中

<com.hjm.bottomtabbar.BottomTabBar
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/button"
    ></com.hjm.bottomtabbar.BottomTabBar>

                                第二步

        在java代码zhong

button = (BottomTabBar) findViewById(R.id.button);
button.init(getSupportFragmentManager())
        .setImgSize(50, 50)//图片大小
        .setFontSize(20)//字体大小
        .setTabPadding(4, 6, 10)//内边距
        .setChangeColor(Color.RED, Color.GREEN)//选中和未选中颜色
        .addTabItem("第一项", null, AFragment.class)
        .addTabItem("第二项", null, BFragment.class)
        .setTabBarBackgroundColor(Color.WHITE)//背景色
        .isShowDivider(false);//是否显示边框

猜你喜欢

转载自my.oschina.net/u/3709181/blog/1589686