BottomTabBar

来源:互联网 发布:恐怖美术馆ib知乎 编辑:程序博客网 时间:2024/06/18 05:26

引用方式:

compile 'com.hjm:BottomTabBar:1.0.0'

1. 首先是XML文件代码:
<com.hjm.bottomtabbar.BottomTabBar     android:id="@+id/bottom_tab_bar"     android:layout_width="match_parent"     android:layout_height="match_parent"/>
2. Activity文件代码:
mBottomTabBar = (BottomTabBar) findViewById(R.id.bottom_tab_bar);mBottomTabBar.init(getSupportFragmentManager())     .addTabItem("第一项", R.mipmap.ic_launcher, OneFragment.class)     .addTabItem("第二项", R.mipmap.ic_launcher, TwoFragment.class)     .addTabItem("第三项", R.mipmap.ic_launcher, ThreeFragment.class)     .addTabItem("第四项", R.mipmap.ic_launcher, FourFragment.class);这里简单的提一句,这个init ( getSupportFragmentManager() )方法一定要第一个调用,没有这个初始化,后边什么也做不了。

简单吧,就这么一个控件就可以了。
当然,你要是想进行一些属性设置的话,需要加上命名空间
xmlns:hjm="http://schemas.android.com/apk/res-auto"

下面就开始详细的解释一下每个参数的含义以及用法:

参数名涵义tab_bar_backgroundBottomTabBar的整体背景颜色tab_img_width图片宽度tab_img_height图片高度tab_font_size文字尺寸tab_padding_top上边距tab_img_font_padding图片文字间隔tab_padding_bottom下边距tab_isshow_divider是否显示分割线tab_divider_height分割线高度tab_divider_background分割线背景tab_selected_color选中的颜色tab_unselected_color未选中的颜色
原创粉丝点击