android:single和android:maxLines的区别
来源:互联网 发布:知乎 农村金融数据 编辑:程序博客网 时间:2024/06/05 05:59
android:singleLine="true"
android:lines="1"
android:maxLines="1"
都可以保证控件只显示一行,但他们还是有区别的
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. 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).
android:maxLines
Makes the TextView be at most this many lines tall. When used on an editable text, the inputType
attribute's value must be combined with the textMultiLine
flag for the maxLines attribute to apply.
android:lines
Makes the TextView be exactly this many lines tall.
maxLines 是在限制高度, singleLine 是强制不让换行。具体效果有什么区别呢? 从高度来讲是一样的,两者肯定都显示一行,但从换行的位置来讲就有区别了,maxLines并不会改变其换行的位置,而singleLine则会。从这个角度讲,singleLine的显示会好一些,因为如果超过一行singleLine会在一行内显示,后面加上"...",而maxlines="1" 则不会,它依然会在原来换行的位置换行,所以有时候一行不满,但是却不显示剩下的部分。
对比下:(Text 的内容为:新建文件夹qqqqqqqqqqqqqqqqqqqqqqqq)
maxLines = “1” 或lines = “1”显示:
singleLine=“true" 显示:
- android:single和android:maxLines的区别
- android中minLines和maxLines的区别
- android中minLines和maxLines的区别
- android中minLines和maxLines的区别
- android中minLines和maxLines的区别
- android中minLines和maxLines的区别
- android:maxLines和android:ellipsize
- Android Studio——android中minLines和maxLines的区别
- singleLine=”true” 和 maxLines=”1″的区别 android:ellipsize="end"无效
- Android maxLines maxLength属性
- android:maxLines和android:ellipsize同时使用导致显示异常
- android:maxLines和android:ellipsize同时使用导致显示异常
- [bug]android:maxLines 和 android:ellipsize不能同时使用
- Android —— TextView中的MaxLines和ellipsize属性的冲突
- android TextView 使用SpannableString数据源时,TextView的maxLines和ellipsize失效
- singleLine=”true” 和 maxLines=”1″的区别
- Android EditText maxLines无效问题
- android TextView 显示不全的问题解决,此问题是设置了maxLines和ellipsize=end情况下发生的!
- Android入门之广播
- POJ 1019 Number Sequence 已被翻译
- Spring MVC 学习中的问题
- 内部类(重点)
- 带有状态的SparkStreaming单词计数程序
- android:single和android:maxLines的区别
- 敏捷开发之Scrum扫盲篇
- 软件测试整理笔记
- 使用随机算法产生一个数,要求把1-1000W之间这些数全部生成
- 拓扑排序(猜序列,LA 4255)
- Android 属性动画(Property Animation) 完全解析
- CentOS系统升级内核
- Java网络编程下之Socket客户端编程
- css基础1-新知识点