BottomNavigationBar简单使用

public class MainActivity extends AppCompatActivity {

    @InjectView(R.id.flContent)
    FrameLayout         flContent;
    @InjectView(R.id.bottom_navigation_bar)
    BottomNavigationBar bottomNavigationBar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        ButterKnife.inject(this);

        initBottomBar();
    }

    private void initBottomBar() {

        BadgeItem bageitem = new BadgeItem();   //角标
        bageitem.setText("5")
                .setGravity(Gravity.RIGHT)
                .setBackgroundColor(Color.RED)
                .setTextColor(Color.WHITE)
                .setHideOnSelect(false)  //点击的时候不让自动隐藏
                .setAnimationDuration(100)
                .show();
        bottomNavigationBar
                .setActiveColor("#00ffd4").setInActiveColor("#abadbb")
                .addItem(new BottomNavigationItem(R.mipmap.conversation_selected_2, "消息").setBadgeItem(bageitem))
                .addItem(new BottomNavigationItem(R.mipmap.contact_selected_2, "联系人"))
                .addItem(new BottomNavigationItem(R.mipmap.plugin_selected_2, "动态"))
                .setFirstSelectedPosition(0)
                .initialise();
        bottomNavigationBar.setTabSelectedListener(new TabSelectedListenerAdapter() {
            @Override
            public void onTabSelected(int position) {  // 当选中的时候
             
            }
        });


    }



}

你可能感兴趣的:(BottomNavigationBar简单使用)