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 = "密码不能为空"
}