<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxEms="5"
android:ellipsize="end"
android:singleLine="true"
android:text="一二三四五六" />
Tip:是 android:maxEms=”5”而不是 android:maxLength=”5”!
android:ems 设置TextView的宽度为N个字符的宽度。
android:maxems 设置TextView的宽度为最长为N个字符的宽度。与ems同时使用时覆盖ems选项。
android:maxLength 限制输入字符数。如设置为5,那么仅可以输入5个汉字/数字/英文字母。