//依赖
compile 'com.hjm:BottomTabBar:1.1.1'
//布局文件
<com.hjm.bottomtabbar.BottomTabBar
android:id="@+id/bottom_tab_bar"
android:layout_width="match_parent"
android:layout_height="match_parent" />
//Activity
BottomTabBar mb = (BottomTabBar) findViewById(R.id.bottom_tab_bar);
mb.init(getSupportFragmentManager())
.setImgSize(50, 50)
.setFontSize(15)
.setTabPadding(4, 6, 10)
.setChangeColor(Color.parseColor("#FFFFC4FD"), Color.DKGRAY)
.addTabItem("Home", R.drawable.homepage, OneFragment.class)
.addTabItem("Read", R.drawable.faxian, TwoFragment.class)
.addTabItem("Me", R.drawable.xinxi, ThreeFragment.class)
.isShowDivider(false)
.setOnTabChangeListener(new BottomTabBar.OnTabChangeListener() {
@Override
public void onTabChange(int position, String name) {
}
});
//Fragment
public class OneFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment3, container, false);
return view;
}
}