我正在构建一个新的 InfoWindow (google maps api v2),我正在努力让我的布局变得完美。 该布局的一部分是这样的:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/txtInfoWindowName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:ellipsize="end"
android:singleLine="true"
android:textColor="#ff000000"
android:textSize="14dp"
android:textStyle="bold"/>
<TextView
android:id="@+id/txtInfoWindowObstacles"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLength="32"
android:lines="1"
android:singleLine="true"
android:textColor="#ff7f7f7f"
android:textSize="14dp"/>
现在,问题出在 android:ellipsize="end".
它应该在末尾画三个点,但它没有那样做。
现在我得到这样的东西:
TextTextTextTextTe
取而代之的是:
TextTextTextTextTe...
我认为这与我使用 layout_width="wrap_content"的事实有关。但我需要它,因为我正在使用 LinearLayout
最佳答案
我试过你的代码,它们工作正常,除了第二个 TextView 具有 android:maxLength="32"
属性,在这种情况下,由于 32 个字符的限制,文本不能省略。但如果您删除它,它会按预期工作。
关于Android ellipsize 不能正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14176329/