How to set the ActionBar title in middle instead of the default left aligned position?

前端 未结 5 949
予麋鹿
予麋鹿 2020-12-07 05:28

Trying to set the ActionBar title in middle instead of the default left aligned position. To do so, based on other answers this is what I\'ve done:



        
5条回答
  •  时光取名叫无心
    2020-12-07 06:27

    You need to use Toolbar in your xml file and you can use TextView inside Toolbar. You can add custom view into Toolbar. Once you done with xml file then you can define Toolbar into Activity class.

    
    
        
    
            
    
        
    
       //Rest of your code
    
    
    

    In Activity class you can define as

    Toolbar toolbar;
    toolbar = (Toolbar) findViewById(R.id.ar_toolbar);
    toolbar.setTitle("");
    

提交回复
热议问题