how to center icons in toolbar in android

后端 未结 7 2014
清歌不尽
清歌不尽 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 22:00

    The toolbar is like any other view. You can add children to it directly and access then like you would for a normal view.

    This is not the exact the answer to your question, but it will tell you the way to go.

    
    
    
        
    
            

    Then in your main fragment or where ever else you can access something like this.

        Toolbar mToolbar = (Toolbar) root.findViewById(R.id.tool_bar);
    
        Button button1 = (Button) mToolbar.findViewById(R.id.button1);
        Button button2 = (Button) mToolbar.findViewById(R.id.button2);
        Button button3 = (Button) mToolbar.findViewById(R.id.button3);
        Button button4 = (Button) mToolbar.findViewById(R.id.button4);
    

    You can use this method to make a custom toolbar any way you like. You will probably want to use a relative layout.

提交回复
热议问题