直播平台搭建源码,TextView限制文字长度且超过显示省略号
一、ellipsize
<!-- Where to ellipsize text. 在哪里省略文本 -->
<attr name="ellipsize">
<enum name="none" value="0" />
<enum name="start" value="1" />
<enum name="middle" value="2" />
<enum name="end" value="3" />
<enum name="marquee" value="4" />
</attr>
二、maxEms
<!-- 使 TextView 最多有这么多 em 宽 -->
<!-- Makes the TextView be at most this many ems wide. -->
<attr name="maxEms" format="integer" min="0" />
三、singleLine
<!-- Constrains the text to a single horizontally scrolling line
instead of letting it wrap onto multiple lines, and advances
focus instead of inserting a newline when you press the
enter key.
The default value is false (multi-line wrapped text mode) for non-editable text, but if
you specify any value for inputType, the default is true (single-line input field mode).
{@deprecated This attribute is deprecated. Use <code>maxLines</code> instead to change
the layout of a static text, and use the <code>textMultiLine</code> flag in the
inputType attribute instead for editable text views (if both singleLine and inputType
are supplied, the inputType flags will override the value of singleLine). } -->
<attr name="singleLine" format="boolean" />
四、maxLength
<!-- 设置输入过滤器以将文本长度限制为指定数字 -->
<!-- Set an input filter to constrain the text length to the specified number. -->
<attr name="maxLength" format="integer" min="0" />
五、使用
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLength="10"
android:maxEms="10"
android:singleLine="true"
android:text />
以上就是直播平台搭建源码,TextView限制文字长度且超过显示省略号, 更多内容欢迎关注之后的文章
标签:singleLine,省略号,text,源码,android,inputType,TextView From: https://www.cnblogs.com/yunbaomengnan/p/16627436.html