问题描述:

1. android:maxLines="1", 只显示一个中文

android:maxLines= android:maxLines=

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

android:maxLines= android:maxLines=

问题原因:

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. 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

具体区别:

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

更多相关文章

  1. android:debuggable属性
  2. Android android:persistentDrawingCache的几个默认属性值介绍
  3. Android ListView 几个重要属性
  4. API 23 widget.ImageView——属性分析
  5. API 23 widget.ProgressBar——属性分析
  6. mainfest文件中android属性

随机推荐

  1. 柔性多模正则匹配引擎
  2. 我对张一得事件的理解
  3. Python自动化测试开发实战 一门能就业的
  4. BAT机器学习面试题及答案(201-250题)
  5. AI笔试面试题库-Python题目解析1
  6. 面试到底面什么?创优视觉科技有限公司告诉
  7. 10道Python题,快来看看你的基础怎么样?
  8. VRRP技术技术介绍及华为资料分享!
  9. 关于机器学习的知识点,全在这篇文章里了
  10. 什么是机器学习?有哪些分类?到底有什么用?终