Android Lollipop, add popup menu from title in toolbar

前端 未结 2 722

I\'m unable to see how adding a popup menu from the title is accomplished like is shown in many of the material design examples. Any help would be much appreciated.

2条回答
  •  日久生厌
    2020-11-30 21:25

    You're going to need to add a Spinner to the Toolbar:

    
    
        
    
    
    

    You will then need to disable the default title:

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    

    You can then retrieve and setup the Spinner as needed in your Activity/Fragment.

提交回复
热议问题