长文本在 ICS 上会转到下一行,但在 GB 及以下版本上不会

2024-04-16

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

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

示例项目

这是一个包含文本视图、警报对话框和两个标准文本视图的示例项目。

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

EDIT

这是我原来问的问题。看来问题比我最初注意到的要多。

Android AlertDialog 在某些设备上不显示整个 setMessage https://stackoverflow.com/questions/9542284/android-alertdialog-not-displaying-entire-setmessage-on-certain-devices

/EDIT

Here are visual examples of what I mean.enter image description here

即使专门为textView设置了多行,文本仍然是一行,只是下面多了一些空行。


以下是警报对话框用于创建视图的布局:

<!--
    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 http://code.google.com/p/android/issues/detail?id=10554

因此它的行为是正确的。

如果您希望它进入多行,请创建您自己的布局文件并将其传递到您的对话框,这样您就可以拥有更多控制权。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

长文本在 ICS 上会转到下一行,但在 GB 及以下版本上不会 的相关文章

随机推荐