带有长文字的对话框按钮未环绕/挤出-Android 5.0 Lollipop上的材质主题 [英] Dialog buttons with long text not wrapping / squeezed out - material theme on android 5.0 lollipop

查看:76
本文介绍了带有长文字的对话框按钮未环绕/挤出-Android 5.0 Lollipop上的材质主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为棒棒糖上的主题主题优化应用程序时,我遇到了这个烦人的问题:

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 button bar width in total, the text isn't wrapped in multiple lines for those buttons as in previous themes. Instead the following buttons get squeezed out of the dialog, being unreachable (see image below).

截屏:

到目前为止,我已经在这个问题上花了很多时间,关于这个问题的唯一话题是我可以在互联网上找到的: https://code.google.com/p/android/issues/detail ?id = 78302

I've spent a lot of time on this problem so far and the only topic regarding it, that I could find on the internet is this: https://code.google.com/p/android/issues/detail?id=78302

所以我在那儿接受建议,并在这里问这个问题.

So I'm taking the advice there and ask this question here..

我尝试过的是调查源代码(按钮使用maxLines = 2定义),并更改buttonBarStyle和buttonBarButtonStyle的不同参数,但没有成功.

What I've tried is looking into the source (buttons are defined with maxLines = 2) and changing different parameters on buttonBarStyle and buttonBarButtonStyle but with no success.

我正在寻找一种简单的样式解决方案,因此不希望使用第三方库.

I'm looking for a simple style-solution and do not want to use third party libraries because of this.

这可能仅仅是一个模拟器问题吗?我不这么认为.

May this only be an emulator problem? I don't think so.

非常感谢您的帮助.预先感谢.

Help is very much appreciated. Thanks in advance.

修改: 要进行跟进,请参阅12月3日我自己的答案,这不是解决方案.

To follow up, see my own answer from Dec 3, which is not a solution.

推荐答案

为感兴趣的任何人总结本主题:

To summarize this topic for anyone interested:

Android Material主题似乎在警报对话框中具有自动按钮宽度跨度的错误.

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

例如,当您有3个按钮(其中一个具有多个单词)时,肯定的按钮可能会从对话框的右侧挤出,而不是将多个单词包装成一个单词的按钮,以便所有按钮都能像基本主题/holo主题一样适合按钮栏中的内容.

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.

似乎没有办法仅通过对buttonBarStyle和/或buttonBarButtonStyle进行更改来解决,因为它们的样式并不限制默认情况下多行换行的按钮文本.

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.

解决此问题的唯一方法似乎是使按钮的标题更短,如果您不想偏离Material的外观和风格(例如使按钮的文本大小变小和/或将allCaps设置为false).

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).

这篇关于带有长文字的对话框按钮未环绕/挤出-Android 5.0 Lollipop上的材质主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆