android - 长文本在 ICS 上转到下一行,但在 GB 及以下

标签 android textview android-4.0-ice-cream-sandwich

我第一次注意到这是 AlertDialogs 将整个消息放在第一行,即使我指定了一个新行(“\n”)。在 ICS 上它显示正确的方式,但对于我来说,我无法让它在 GB 上工作。

最近又遇到了。我看不出它在 ICS 上运行良好但在 GB 及以下版本上运行良好的任何原因。

示例项目

这是一个带有 TextView 、警报对话框和两个标准 TextView 的示例项目。

https://github.com/T3hh4xx0r/Text-Example

编辑

这是我最初提出的问题。不过,问题似乎比我最初注意到的要多。

Android AlertDialog not displaying entire setMessage on certain devices

/编辑

这里是我的意思的视觉示例。 enter image description here

即使专门为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/

相关文章:

android - Android 中类似 UIPopoverViewController 的元素

android - 代码适用于 Gingerbread (2.3.6) 而不适用于 ICS (4.0.4)

Android - 以编程方式更改微调器弹出对话框颜色

android - 如何将 json 序列化对象传递给 android 中的 Intent?

java - 使用 volley 发出请求时未得到响应

android - Android-Java 通信的 StreamCorruptedException

java - 使用java单击按钮时交换两个 TextView 值

android - 你如何在android中使用setId?

iphone - 如何检查 TextView 中输入的拼写?

java - Android 2.3.3 互联网适用于我的 Galaxy S 但不适用于我的 Galaxy Tab? (权限?)