TextView一些技巧
来源:互联网 发布:js分页代码实例 编辑:程序博客网 时间:2024/06/08 15:35
1.Android中如何让TextView显示指定的行数并且多出的部分显示省略号
大家都知道,如果要让TextView只显示一行,多出部分用省略号代替的话非常容易,只需要为xml文件中的TextView控件添加Android:singleLine="true"即可,那么如果我想让它显示多行的时候应该怎么做呢?其实也很简单,只要添加以下两个属性就可以了:
android:lines="2"
android:ellipsize="end"
这样就可以让TextView最多显示2行,如果要显示指定的其它行数,只要修改上面的android:lines属性即可,不过这里有个不好的地方,比如你设置了最多显示两行,如果内容用一行就可以全部显示了,这时候TextView还是会占用两行的高度空间。
如果不想让TextView占用固定的高度,可以改用android:maxLines="2"这个属性来解决
2.TextView实现一行居中显示,多行居左显示。
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" /> </LinearLayout></RelativeLayout>3.
TextView的android:maxHeight,android:minHeight的正确设置
设置最大(最小)高度(宽度)时,
需要同时设置Android:adjustViewBounds="true",这样设置才会生效。
在代码中设置时,需要setAdjustViewBounds为true。一个layout的实例:
android:adjustViewBounds="true"
android:maxHeight="150.0dip"
android:maxWidth="150.0dip"
android:minHeight="33.0dip"
android:minWidth="48.0dip"
阅读全文
0 0
- TextView一些技巧
- TextView使用一些小技巧
- TextView的一些小技巧
- Android小技巧——TextView的一些小技巧
- Android小技巧——TextView的一些小技巧
- android TextView EditTextView一些技巧使用 (视图代码布局)
- TextView的常用技巧
- textView用法技巧
- TextView中的使用技巧
- 5.Android Textview 技巧
- TextView 小技巧
- TextView使用技巧
- android textview小技巧
- Android TextView使用技巧
- TextView的一些使用
- textView 的一些方法
- Textview一些小知识
- 一些技巧
- 【转】MyBatis传多个参数的方法
- [莫比乌斯反演+数状数组] BZOJ3529: [Sdoi2014]数表
- python高效过滤出文件夹下指定文件名结尾的文件
- Macaca之常见参数
- python logging 模块(一)
- TextView一些技巧
- R绘图系统概要总结
- 微信小程序特性:
- Oracle执行计划跟踪样例
- Spring项目开发小记3
- Android ADB
- Linux 下安装 NVIDIA 显卡驱动
- 完整的数据分析流程
- postman接口工具-Invalid URI "http:///%7B%7Burl%7D%7Dapi/document/getHelpDocumentUrl?appType=1"