带标签的文本

  1. android:maxLines=”1”, 还没满一行就会会显示省略号

  2. android:singleLine=”true”, 正常显示

问题原因:

Google Document 的解释:

android:maxLines
Makes the TextView be at most this many lines tall.

android: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.
55

具体区别:

   android:maxLines是限制高度,android:singleLine是强制不让换行。从高度上来讲二者是一样的,都只显示了一行字串, 但从换行的角度来讲,android:maxLines并不会改变换行的位置,而android:singleLine则会改变换行的位置。所以,如果要截取字符串并追加省略号显示,尽量用android:singleLine属性。如果要控制显示行数,尽量用android:maxLines属性。

更多相关文章

  1. android ImageView 显示本地图片
  2. Android的Recyclerview的使用
  3. android 横竖屏判断
  4. Android(安卓)RecyclerView 设置显示滚动条属性后,滚动条不显示踩
  5. android xml控件属性
  6. Android(安卓)Edittext 显示光标 获取焦点 监听焦点
  7. Android(安卓)API中文文档EditText
  8. android logo:内核、android开机动画
  9. android:screenOrientation属性

随机推荐

  1. 探索 Android(安卓)系统启动 - 当我们按
  2. Android中Notification的小发现
  3. Android实现截屏与截长图功能
  4. 由android:process引发的内存限制的问题
  5. Android之sp和dip的区别
  6. Android(安卓)Switch控件修改样式
  7. 保证Android手机安全的八条建议
  8. RSA公钥、私钥的生成详解,包含Java、PHP
  9. Android(安卓)M PackageManager应用程序
  10. Android中使用双层ViewPager2+Fragment+T