您的位置:首页 > 其它

Tablayout变颜色 以及Fragment进行切换

2017-12-14 00:00 260 查看

第一步

在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);//是否显示边框
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  tablayout