Android: CollapsingToolbarLayout centers expanded text but not collapsed text

前端 未结 4 1434
感动是毒
感动是毒 2021-02-05 15:50

I have a CollapsingToolbarLayout that is defined to center both in collapsed and in expanded modes:



        
4条回答
  •  执笔经年
    2021-02-05 16:07

    It may be late, but what I found is, the your title is in center in the title's view and not the whole toolbar. It happened with me, when I didn't had the up/back button on the left and had a single icon on the right.

    So if you have back/up button, it should be exactly in the center because on the left and right you have 1 icon. But, this didn't happened because when you set the up/back button, it adds some right margin (you can see this behavior on the normal toolbar, with left title gravity).

    So by considering that, the in the remaining area, your title is in the center. But, not center considering toolbar's width, center in title view's available width.

    EXPERIMENT: You can try adding a second icon on the right and it will be very much in the center. Just a hack. Ugly hack.

提交回复
热议问题