Dialog buttons with long text not wrapping / squeezed out - material theme on android 5.0 lollipop

前端 未结 6 1401
自闭症患者
自闭症患者 2021-02-01 14:37

While optimizing an app for material theme on lollipop, I\'m encountering this annoying problem:

Whenever there is long text on dialog buttons, that doesn\'t fit the but

6条回答
  •  北海茫月
    2021-02-01 15:03

    To summarize this topic for anyone interested:

    Android Material theme seems to have a bug with automatic button-width-span in alert dialogs.

    When you have for example 3 buttons, one of which having more than one word, the positive button will likely be squeezed out of the dialog to the right, instead of the button with more than one word being wrapped in multiple lines, so that all buttons fit in the button bar like the basic theme / holo theme are doing.

    There don't seem to be solutions solely by applying changes to buttonBarStyle and/or buttonBarButtonStyle, since their styles are not restricting button texts being wrapped in multiple lines by default.

    Sure, Material theme dialog buttons require more space than in other themes in general, due to caps, boldness and generous padding and background, but that is not the source of the problem, it just makes it appear sooner than if the styling was less space requiring.

    The only way to solve this problem seems to be giving your buttons shorter titles, if you don't want to style away from Material's look and feel (like making the button text size smaller and / or setting allCaps to false).

提交回复
热议问题