How to create the custom item of Bottomnavigationview Android?

前端 未结 3 1132
长情又很酷
长情又很酷 2021-02-08 14:30

I am using the Bottomnavigationview for tab-bar in my application, for it, i am using the following code.Please check it once.

Layout :-

3条回答
  •  清酒与你
    2021-02-08 15:18

    If you are using androidX , please refer below code :

      BottomNavigationView mbottomNavigationView =findViewById(R.id.navigation);
    
            BottomNavigationMenuView mbottomNavigationMenuView =
                    (BottomNavigationMenuView) mbottomNavigationView.getChildAt(0);
    
            View view = mbottomNavigationMenuView.getChildAt(1);
    
            BottomNavigationItemView itemView = (BottomNavigationItemView) view;
    
            View cart_badge = LayoutInflater.from(this)
                    .inflate(R.layout.notification_badge,
                            mbottomNavigationMenuView, false);
    
            itemView.addView(cart_badge);
    

提交回复
热议问题