Extended Toolbar with Custom View not Displaying with Full Width

后端 未结 3 1947
眼角桃花
眼角桃花 2021-02-03 12:45

I went through lots of answers here related to Toolbar but none of the answers could help me.

What I\'m trying to achieve is to have an extended toolbar whhich will disp

3条回答
  •  攒了一身酷
    2021-02-03 13:07

    From the Toolbar documentation:

    One or more custom views. The application may add arbitrary child views to the Toolbar. They will appear at this position within the layout. If a child view's Toolbar.LayoutParams indicates a Gravity value of CENTER_HORIZONTAL the view will attempt to center within the available space remaining in the Toolbar after all other elements have been measured.

    So from what it look like, your custom view is behaving as it should. The options menu is taking up a certain amount of space in your toolbar, so the Toolbar is measuring the remaining space for your custom view to fit in.

提交回复
热议问题