android TextView常用属性

TextView是一个强大而基础的控件,掌握它的属性还是很有必要。

android:autoLink    //将文本添加为链接形式,可以是网址、电话、邮箱等
android:linksClickable  //设置链接是否点击连接,即使设置了autoLink。
android:textColorLink   //文字链接的颜色.

//根据TextView.BufferType在创建字符时,使用normal-SpannedString,spannable-SpannableString,editable-SpannableStringBuilder
android:bufferType 

//在文字周围添加一个drawable
android:drawableBottom
android:drawableEnd
android:drawableLeft
android:drawableRight
android:drawableStart
//文字与drawable间的距离
android:drawablePadding
//为drawable着色
android:drawableTint
//着色模式
android:drawableTintMode

android:editable    //设置是否可编辑。对EditText有效

//设置以“...”代替省略内容的位置,可以设置位置。
android:ellipsize   
//在ellipsize指定marquee的情况下,设置重复滚动的次数,当设置为marquee_forever时表示无限次。
android:marqueeRepeatLimit

android:singleLine  //设置单行

//可能与系统语言有关,这里是一个汉字字符宽度
//设置TextView的宽度,超过文本会换行。当 android:layout_width="match_parent" 时该属性不会生效
android:ems

android:fontFamily  //设置字体
android:gravity //文本在TextView中位置,文本需要比View小
android:hint    //text属性为空时,显示的默认文本
android:textColorHint       //设置提示信息文字的颜色,默认为灰色。与hint一起使用。
android:includeFontPadding //设置文本是否包含顶部和底部额外空白,默认为true。
android:letterSpacing   //字母间距,float类型
android:textScaleX  //设置文字之间间隔,默认为1.0f
android:lineSpacingExtra    //行间距
android:lineSpacingMultiplier设置行间距的倍数。如”1.2android:lines   //行数
android:scrollHorizontally  //设置文本超出TextView的宽度的情况下,是否出现横拉条。

//设置阴影
android:shadowColor 
android:shadowDx 
android:shadowDy 
android:shadowRadius

android:textAppearance  //设置文字外观。
android:textColor   //文本颜色
android:textColorHighlight  //被选中文字的底色,默认为蓝色
android:textIsSelectable    //设置文本能否被选中 好像没用
android:textStyle           //粗体、斜体
android:typeface            //设置文本字体
append(CharSequence text)   //追加文本,需要为BufferType.EDITABLE 模式

EditText:

//设置软键盘回车键的样式。 http://blog.csdn.net/shaoyezhangliwei/article/details/44805999
android:imeOptions 

android:inputType   //设置文本的类型

android:selectAllOnFocus    //选中时获得焦点

方法:

//文字改变监听
addTextChangedListener(TextWatcher watcher) 
View
android:alpha   //透明度
android:background  //背景

//关联方法: setDrawingCacheQuality(int) 属性说明: "设置绘图时半透明质量。有可以取以下3个值 auto——默认,由框架决定 high——高质量,使用较高的颜色深度,消耗更多的内存 low——低质量
android:drawingCacheQuality 

android:layerType   //设置软/硬加速
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值