I'm using a custom layout for my title bar, based on a ConstraintLayout
. I need to center the title text without overlapping the buttons on either side. Currently I've got the title centered between the side buttons, but as they're different widths the title is not centered within the parent view.
This is what it currently looks like (centered between the two buttons rather than centered in the parent):
Is there any way to center the title within the parent, while ensuring it doesn't overlap the button text on either side (as this can change)?
To make it more complicated, I'd also like it to be the title that gets compressed instead of the button text if there isn't space for both to be displayed in full.
If I constrain both edges of my title to the parent and set it to wrap width then it almost works, until the button text gets a bit long.