我希望有一个单一的内衬的TextView显示了3个点在结束的时候,文本的长度超过TextView的。我不知道为什么 - 但我不明白这一点。
I want to have a single lined TextView to show up 3 dots at the end when the text is longer than the TextView. I don't know why - but i don't get it.
我已经包裹着我的头,围绕类似计算器的问题 - 但我结束了无解。也许有人有一些有用的提示。
I already wrapped my head around similar stackoverflow questions - but i ended up with no solution. Maybe someone has some useful hints.
<LinearLayout android:layout_height="wrap_content" android:layout_width="fill_parent"
android:orientation="vertical">
<TextView android:textStyle="bold" android:text="Full Name" android:layout_height="wrap_content" android:textSize="16sp"
android:layout_width="wrap_content" android:id="@+id/lName"
android:layout_gravity="center_vertical" android:maxLines="1" android:ellipsize="end"/>
</LinearLayout>
线性布局上面的嵌套到其他2线布局。这也许是知道的重要。我已经尝试过的属性为单线过,但有人说这是去precated,它不工作呢。
The linear Layout above is nested into 2 other Linear Layouts. Maybe this is important to know. I already tried the attribute "singleLine" too, but some say this is deprecated and it doesnt work anyway.
添加以下样式的样式文件(通常 styles.xml
):
Add the following styles in your styles file (typically styles.xml
):
<style name="autoscroll">
<item name="android:singleLine">true</item>
<item name="android:ellipsize">marquee</item>
<item name="android:marqueeRepeatLimit">marquee_forever</item>
<item name="android:focusable">true</item>
<item name="android:focusableInTouchMode">true</item>
<item name="android:scrollHorizontally">true</item>
</style>
然后样式 @风格/自动滚屏
添加到您的的TextView
:
<TextView android:id="@+id/lName"
android:style="@style/autoscroll" />
您可以轻松地重复你的自动滚动功能,当你想通过这种方式。
You can reuse your autoscroll feature easily when you want this way.