问题描述:

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

具体区别:

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

更多相关文章

  1. android广播监听短信并显示内容
  2. android:debuggable属性
  3. Android(安卓)android:persistentDrawingCache的几个默认属性值
  4. Android设置文本框单行多行显示
  5. Android(安卓)ExpandableListView同时显示多种不同类型字列表
  6. 直播软件源码android ui LinearLayout中按扭平行显示
  7. Android使用AchartEngine绘制曲线图
  8. android > WebView > 布局
  9. [置顶] Android(安卓)百度地图 简单实现--- 美食搜索

随机推荐

  1. Android(安卓)studio出现Connection refu
  2. Android(安卓)Studio Gradle使用笔记
  3. android paint api drawText 绘制字体字
  4. Ubuntu 11.10 64bit系统编译android 2.3
  5. 支付宝蜻蜓刷脸支付——Android
  6. 移动开发者必须知道的Android框架推荐
  7. Android(安卓)怎么判断Wifi 是否可用
  8. Preference 使用方法详解
  9. Android如何用代码重复加载同一个xml
  10. Android:使用canvas绘制饼状统计图(自动适