Android(安卓)官方自带的Edittext悬浮标签
16lz
2021-01-25
效果图:
使用方法:
依赖:
compile 'com.android.support:design:22.2.0'
使用:
布局:
.support.design.widget.TextInputLayout android:id="@+id/textInputLayoutName" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="30dp"> "@+id/editTextName" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="请输入账号" android:textColorHint="@color/colorGray" />.support.design.widget.TextInputLayout>
代码中校验edittext:
if(TextUtils.isEmpty(text1)){ //红色提示语 textInputLayoutName.setError("账号不能为空!");}else{ //这一步主要作用是消除edittext非空时下面的红色提示 textInputLayoutName.setError(null);}
更多相关文章
- Android(安卓)studio 类似于eclipse 中的 Ctrl+1 快捷键(quick f
- Android(安卓)Studio打包Signed APK 碰到的一个Error
- 6.22 android计算字符高度宽度,红蓝3D图片的制作原理及NDK生成实
- AutoCompleteTextView和MultiAutoCompleteTextView
- 在命令行中通过adb shell am broadcast发送广播通知
- Android(安卓)修改 AndroidManifest package
- C++调用Android函数弹出一个提示框中出现的问题总结
- Android(安卓)ApiDemos示例解析(102):Views->Auto Complete->4.
- Android怎么获取ListView的值