关于Android studio中EditText的setError文字不显示的问题
2016-01-20 16:57
537 查看
Android系统提供的控件EditText,我们在使用其方法setError时,会出现错误框显示但是文字不显示的问题。
原因是系统部分主题的setError文字和背景都是白色,例如系统自带的几个light的theme。
既然是主题的问题,那我们可以尝试自定义主题并进行适当的修改,在
完整文件内容如下:
原因是系统部分主题的setError文字和背景都是白色,例如系统自带的几个light的theme。
既然是主题的问题,那我们可以尝试自定义主题并进行适当的修改,在
res/values/styles.xml文件中,在自定义主题里加入一个item:
完整文件内容如下:
<resources xmlns:android="http://schemas.android.com/apk/res/android"> <!-- Base application theme, dependent on API level. This theme is replaced by AppBaseTheme from res/values-vXX/styles.xml on newer devices. --> <style name="AppBaseTheme" parent="@android:style/Theme.Light.NoTitleBar"> <item name="android:textColorPrimaryInverse">@android:color/primary_text_light</item> </style> <!-- Application theme. --> <style name="AppTheme" parent="AppBaseTheme"> </style> <style name="LoginFormContainer"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:padding">16dp</item> </style> <style name="edittext_style" parent="@android:style/Widget.EditText"> <item name="android:background">@drawable/bg_edittext</item> <item name="android:paddingLeft">10dip</item> <item name="android:paddingTop">8dip</item> <item name="android:paddingBottom">8dip</item> </style> </resources>
相关文章推荐
- Android Studio 的安装
- Android动态加载进阶 代理Activity模式
- Qt入门一之用于android
- Android 高清加载巨图方案 拒绝压缩图片
- 下拉刷新框架android-Ultra-Pull-To-Refresh示例
- 通过浏览器调用Android或iOS应用
- Android中Services之异步IntentService
- Android 布局1.属性介绍
- 如何姿势正确地开始一个Android项目
- 假设写一个android桌面滑动切换屏幕的控件(一)
- android 开发
- Android Studio SDK 更新方法
- Android群英传(作者:徐宜生)地址
- Android开发实践:使用Service还是Thread
- android 监听USB连接状态
- Android自定义ViewGroup添加组合控件的子view
- Android 如何引用com.android.internal.R目录下的资源
- 【android】仿知乎ScrollView滚动改变标题栏透明度
- Android自定义ViewGroup时子view的释放
- Android特效专辑(七)——飞机升空特效,一键清理缓存,灵活运用动画会有不一样的感受