TextView,EditView,Button控件,常用的属性笔记(1)

EditView的属性

ems :设置Edittext的宽度为10个字符的宽度。

android:ems="10"

 autofillHints 

 inputType :输入的类型

layout_weight:只有在线性布局,且宽度设为“wrap_content”

\n:换行

<string name="about">请联系我\n电话:18110644661\nEmailhsz@qq.com</string>

autoLink:自动识别链接

     <!-- android:autoLink="web"-设置自动识别链接,值web为匹配Web网址 -->

     <!--android:autoLink="phone"-设置自动识别链接,值phone为匹配电话号码 -->

     <!-- android:autoLink="email"-设置自动识别链接,值email为匹配Email地址 -->

     <!-- android:autoLink="all"-设置自动识别链接,值all为匹配所有 -->
 

文字的阴影

android:shadowColor="#ff0000" 
android:shadowDx="5" 
android:shadowDy="5" 
android:shadowRadius="5"

文字的变形

android:rotation="-39" 
android:rotationX="26" 
android:rotationY="77"

设置文本

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { 
    textView.text = Html.fromHtml("替换为<Font color='red'>HTML</Font>文档",             
    Html.FROM_HTML_MODE_LEGACY) 
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) {
    textView.text = Html.fromHtml("替换为<Font color='red'>HTML</Font>文档") 
}

editText.error的使用

val name = editText.text.toString()
val password = editText1.text.toString()
if (name.isEmpty()) {
     editText.error = "账号不能为空"
} else if (TextUtils.isEmpty(password)) {
     editText1.error = "密码不能为空"
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值