Search code examples
androidxmlbottomnavigationview

is there a guide or link for learning how to create this xml view?


Hi I know it is maybe a simple question but i dont know what to search to find my question I want to create this bottom navigation view which i can do create bottom navigation in android

but as obvious in the second photo when we hold our finger on button it happen to something that i cant create and I want you to help to create or link to some guide for creating this: button in bottom navigation that expands


Solution

  • First, you need to update the dependency

    compile ‘com.android.support:design:25.0.0’
    

    Design for bottom navigation https://xmleditoronline.org/?id=ac92e01a0aa54dbd376795b4742a41ba-S2nSrO

    And here is how you should format the items under them https://xmleditoronline.org/?id=ac92e01a0aa54dbd376795b4742a41ba-1dKLUF

    BottomNavigationView bottomNavigationView = (BottomNavigationView)
                    findViewById(R.id.bottom_navigation);
    
    bottomNavigationView.setOnNavigationItemSelectedListener(
            new BottomNavigationView.OnNavigationItemSelectedListener() {
                @Override
                public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                    switch (item.getItemId()) {
                        case R.id.action_favorites:
    
                            break;
                        case R.id.action_schedules:
    
                            break;
                        case R.id.action_music:
    
                            break;
                    }
                    return false;
                }
    });