LoginSignup
5
5

More than 5 years have passed since last update.

TextViewのellipsizeを設定して落ちた時の対応

Last updated at Posted at 2014-07-07

概要

TextViewのEllipsizeを設定して「...」を表示させる設定をした場合、GALAXY J(Android4.3.0)でArrayIndexOutOfBoundsExceptionで落ちる現象が発生した。

詳細

以下のようなXML定義したところ問題が発生した。

<TextView
   android:id="xxx"
   android:ellipsize="end"
   android:scrollHorizontally="true"
   android:singleLine="true"/>

文字列は動的に設定して、「...」が発生する文字列の場合に発生しました。
GALAXY S2(Android4.0.4)では発生しないため、特定のバージョンでのバグの可能性があります。

解決法

<TextView
    android:id="xxx"
    android:scrollHorizontally="true"
    android:lines="1"
    android:singleLine="true"/>

android:singleLineをandroid:lines="1"とandroid:singleLine="true"で回避出来る模様。
では、2行以上で「...」を実現したい場合はどうすればいいか?は今のところわかってません。
Google先生が早くバグフィックスしてくれることを祈りましょう。
ちなみに私は仕様を変更して逃げました。

参考

Crash when using ellipsize="start" (Jelly Bean)

5
5
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5