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);

    }


发布了1999 篇原创文章 · 获赞 514 · 访问量 254万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 成长之路 设计师: Amelia_0503

分享到微信朋友圈

×

扫一扫,手机浏览