textView如果想要强制换行的话,必须先把TextView显示方式修改为多行(android:singleLine="false"),然后才能换行。
方法一般用两种:
1、在字符串里加入“\n”,如"abc\nrc"
2、把TextView设置为固定宽度,然后让系统自动换行。如android:layout_width="100dp"
扩展资料
Class Overview
向用户显示文本,并可选择允许他们编辑文本。TextView是一个完整的文本编辑器,但是基类为不允许编辑;其子类EditText允许文本编辑。
允许用户复制部分或全部内容,将其粘贴到别的地方,设置XML属性Android:textisselectable :“真” 或设置相关方法 settextisselectable 为“真”。textisselectable flag 允许用户在TextView选择手势,从而触发系统内置的复制/粘贴控件。
Displays text to the user and optionally allows them to edit it. A TextView is a complete text editor, however the basic class is configured to not allow editingseeEditTextfor a subclass that configures the text view for editing.
To allow users to copy some or all of the TextView's value and paste it somewhere else, set the XML attributeandroid:textIsSelectableto "true" or callsetTextIsSelectable(true). ThetextIsSelectableflag allows users to make selection gestures in the TextView, which in turn triggers the system's built-in copy/paste controls.
参考资料来源:百度百科:TextView
1、让textView里面的内容水平居中
设置textView属性:android:gravity="center_horizontal"
2、让textView控件在它的父布局里水平居中
设置textView属性:android:layout_gravity="center_horizontal"
扩展资料
android textView的属性介绍
1、android:autoLink
设置是否当文本为URL链接/email/电话号码/map时,文本显示为可点击的链接。可选值(none/web/email/phone/map/all)
2、android:autoText
如果设置,将自动执行输入值的拼写纠正。此处无效果,在显示输入法并输入的时候起作用。
3、android:bufferType
指定getText()方式取得的文本类别。选项editable 类似于StringBuilder可追加字符,也就是说getText后可调用append方法设置文本内容。
4、android:capitalize
设置英文字母大写类型。此处无效果,需要d出输入法才能看得到,参见EditView此属性说明。
5、android:cursorVisible
设定光标为显示/隐藏,默认显示。
参考资料来源:百度百科-TextView
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)