Android的EDITTEXT光标不可见 [英] Android Edittext cursor invisible

查看:274
本文介绍了Android的EDITTEXT光标不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序一个EditText,将显示光标在正确的Froyo或姜饼,但是在以后的SDK光标是看不见的。我在网上找到了解决办法是设置了android:textCursorDrawable =@空,这样的EditText将使用游标的字体颜色。但是,由于我的minSdkVersion是8,我没有访问该属性。

I have an edittext in my application that will show the cursor correctly in Froyo or Gingerbread, however in later sdks the cursor is invisible. I have found online the solution is to set the android:textCursorDrawable="@null" so that the edittext will use the font color for the cursor. However, since my minsdkversion is 8, I do not have access to that property.

他们是不是一种选择性地添加基于你在SDK的属性?或可能的方式来解决,这样我可以有新旧SDK版本可见游标?

Is their either a way to selectively add a property based on the sdk you are on? Or possibly a way to work around this so that I can have visible cursors on both older and newer sdk versions?

推荐答案

我不知道你当前的设置,但使用该财产的一种方式是根据不同的Andr​​oid版本使用不同的布局文件夹。 的android:textCursorDrawable 是API 12引入的,所以你可以像布局-V12 这将是一个布局文件夹的属性用在该API为12或更大。在此文件夹中的布局中使用该属性是有效的。
对于较低的版本,升级Froyo 姜饼,你没有任何问题,所以你可以使用默认文件夹,布局。最终您将有两个布局文件夹(包含相同的布局文件):

I don't know your current setup, but one way to use that property is to use different layouts folders based on various android versions. android:textCursorDrawable is a property introduced in API 12 so you could have a layout folder like layout-v12 which will be used where the API is 12 or greater. In the layouts from this folder the use of the property is valid. For lower versions, Froyo and Gingerbread, you don't have any problems so you would use a default folder, layout. In the end you'll have two layouts folder(containing the same layout files):

layout // don't need the property
layout-v12 // use the property

这省去了API 11,我不知道这对你是一个大忌。

That leaves out API 11, I don't know if this is a deal breaker for you.

这篇关于Android的EDITTEXT光标不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆