how to center icons in toolbar in android

后端 未结 7 2007
清歌不尽
清歌不尽 2021-02-07 21:29

I asked a similar question here... I got some tutorials in the answers. But this question is diffrenet. because none of that method do not works in my project.

I want

7条回答
  •  伪装坚强ぢ
    2021-02-07 21:39

    I know, that this solution is terrible, but for me it works.

    Firstly, in LinearLayout you could place 3 Toolbars instead of 1:

    
    
        
    
        
    
        
    
    
    

    Each toolbar should have it`s own menu resource.

    Then, you will get something like that: Icons are centered, but left icon is not aligned to left border

    Finally, to align left icon you can simply set this parameter for left toolbar:

    android:layoutDirection="rtl"
    

    The result is: The desired order

提交回复
热议问题