博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android 3.2及以上系统 EditText光标不可见的问题
阅读量:2359 次
发布时间:2019-05-10

本文共 972 字,大约阅读时间需要 3 分钟。

这个问题主要出现在当在Android Manifest文件中设置android:minSdkVersion或android:targetSdkVersion为13或更高的数值后,原因是因为系统默认的主题所致,所以要进行特别的定义。

通过以下方法来解决:

android:textCursorDrawable="@null"
 

这样会使光标的颜色与文字颜色的属性一致

另外也可以用自定义的图片资源,但好像在4.2的系统上无效,设置为null是OK的~

这个属性在低版本的系统上会被忽略,不用担心没有这个属性会造成崩溃。

下面是stackoverflow上的讨论:

56
accepted

Setting the android:textCursorDrawable attribute to @null should result in the use ofandroid:textColor as the cursor color.

|
 
1  
oh man that is SO much more efficient than conjuring up a drawable for the cursor to be black!! I love Android to death but this is such an incredibly bad default behavior... someone really needs to be smacked for it. –   
4  
android 3.2 and above .. sucks –   
 
Although if you target >3.2 in your manifest you can use it and it will be ignored for lower versions –   
 
in fact I have just noticed that JellyBean 4.2 does not show the cursor if you use the drawable cursor option ! @null is the way to go! –   

转载地址:http://zoitb.baihongyu.com/

你可能感兴趣的文章
ImageView的缩放模式ScaleType
查看>>
用javadoc命令生成api帮助文档
查看>>
MBR简介
查看>>
查看Linux内核版本号与发行版本号
查看>>
Ant中设置特定的jdk版本
查看>>
解决ant编译中出现“includeantruntime was not set”警告的问题
查看>>
用ant进行编译和打包
查看>>
解决Ubuntu 10.04更改主机名之后sudo报错的问题
查看>>
Ubuntu 10.04设置终端窗口的默认大小
查看>>
windowSoftInputMode属性详解
查看>>
Android Studio快捷键
查看>>
Java中final的用法总结
查看>>
四种获取Class对象的方法-Java反射机制
查看>>
eclipse用空格代替制表符
查看>>
Squid中文权威指南-第4章 快速配置向导
查看>>
Squid中文权威指南-第5章 运行Squid
查看>>
Squid中文权威指南-第6章 访问控制
查看>>
Squid中文权威指南-第7章 磁盘缓存基础
查看>>
Squid中文权威指南-第8章 高级磁盘缓存主题
查看>>
Squid中文权威指南-第9章 Cache拦截
查看>>