我第一次注意到这是 AlertDialogs 将整个消息放在第一行,即使我指定了一个新行(“\n”)。在 ICS 上它显示正确的方式,但对于我来说,我无法让它在 GB 上工作。
最近又遇到了。我看不出它在 ICS 上运行良好但在 GB 及以下版本上运行良好的任何原因。
示例项目
这是一个带有 TextView 、警报对话框和两个标准 TextView 的示例项目。
https://github.com/T3hh4xx0r/Text-Example
编辑
这是我最初提出的问题。不过,问题似乎比我最初注意到的要多。
Android AlertDialog not displaying entire setMessage on certain devices
/编辑
这里是我的意思的视觉示例。
即使专门为textView设置了多行,文本仍然是一行,只是下面多了一个空行。
最佳答案
这是警报对话框用于创建 View 的布局:
<!--
This layout file is used by the AlertDialog when displaying a list of items.
This layout file is inflated and used as the TextView to display individual
items.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/primary_text_light_disable_only"
android:gravity="center_vertical"
android:paddingLeft="14dip"
android:paddingRight="15dip"
android:ellipsize="marquee"
/>
如您所见,椭圆大小设置为选取框,所以我不认为它是为了允许多行而编写的。
目前有一个错误未显示椭圆点:http://code.google.com/p/android/issues/detail?id=10554
因此它的行为是正确的。
如果您希望它进入多行,请创建您自己的布局文件并将其传递给您的对话框,这样您无论如何都拥有更多控制权。
关于android - 长文本在 ICS 上转到下一行,但在 GB 及以下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9795347/