效果

android带气泡的第三方选项卡_初始化

依赖

compile 'com.ashokvarma.android:bottom-navigation-bar:1.3.0'


OnCreate中初始化

initBottom();

默认选中0
showFragment(0);


然后具体实现

private void showFragment(int position) {
FragmentManager supportFragmentManager = getSupportFragmentManager();
FragmentTransaction transaction = supportFragmentManager.beginTransaction();
transaction.replace(R.id.fl_fragment, FragmentFactory.getFragemt(position)).commit();
}

private void initBottom() {


numberBadgeItem = new BadgeItem()
// .setBorderWidth(4) 边框
.setBackgroundColor(Color.RED)
.setText("6");
// .setHideOnSelect(autoHide.isChecked()); 点中后干掉

bntBottom
.setActiveColor(R.color.maincolor)
.addItem(new BottomNavigationItem(R.drawable.conversation_selected_2, "消息").setBadgeItem(numberBadgeItem))

.addItem(new BottomNavigationItem(R.drawable.contact_selected_2, "联系人"))
.addItem(new BottomNavigationItem(R.drawable.plugin_selected_2, "动态"))
.setFirstSelectedPosition(0)
.initialise();

//监听底部导航
bntBottom.setTabSelectedListener(this);
}

@Override
public void onTabSelected(int position) {
//当前切换时候调用
showFragment(position);

}