Long text goes to next line on ICS, but not on GB and below

淺唱寂寞╮ 提交于 2020-01-02 03:25:33

问题


The first time I noticed this was with AlertDialogs putting the entire message on the first line, even when I specified a new line("\n"). On ICS it displays the correct way, but for the life of me, I couldn't get it to work on GB.

Recently I've run into it again. I don't see any reason for it working fine on ICS but not GB and below.

EXAMPLE Project

Heres an example project with a textview, alertdialog, and two standard textviews.

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

EDIT

Heres the original question I asked. Seems the problem is more than I originally noticed though.

Android AlertDialog not displaying entire setMessage on certain devices

/EDIT

Here are visual examples of what I mean.

Even specifically setting multiple lines for the textView, the text is still one line, but with extra blank lines below.


回答1:


Here is the layout that the alertdialog is using to create your 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"
/>

As you can see the ellipsize is set to marquee, so I don't believe it was ever written with the intention to allow multilines.

There is a bug open at the moment that ellipse dots are never shown: http://code.google.com/p/android/issues/detail?id=10554

Therefore it is acting correctly.

If you want it to go onto multiple lines, create your own layout file and pass that to your dialog, that way you have more control anyway.



来源:https://stackoverflow.com/questions/9795347/long-text-goes-to-next-line-on-ics-but-not-on-gb-and-below

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!