【问题标题】:EditText cursor is not visible on Android 5.0 (Lollipop)EditText 光标在 Android 5.0 (Lollipop) 上不可见
【发布时间】:2015-08-03 03:58:27
【问题描述】:

EditText 光标在 Android 4.0 或更低版本上可见,但在 Android 5.0 (Lollipop) 版本中不显示。我该如何解决这个问题?

【问题讨论】:

  • 也许您的光标与背景颜色相同?您可以将光标的颜色更改为其他背景颜色并检查。
  • 你能把你的xml贴在这里
  • 我已经解决了这个问题,像这样link

标签: android android-edittext cursor


【解决方案1】:

在您的 XML 文件中添加android:cursorVisible="true"android:focusableInTouchMode="true"

例子:

<EditText 
    android:id="@+id/textLabel"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:cursorVisible="true" 
    android:focusableInTouchMode="true"/>

有时 EditText 需要焦点才能显示光标,所以它可能会对您有所帮助。

【讨论】:

    【解决方案2】:

    我已经解决了这个问题,像这样link

    问题是我是这样使用它的:

    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:maxLength="50"
        android:textColor="#666666"
        android:textCursorDrawable="#666666"/>
    

    如果你要使用textCursorDrawable,你应该使用drawable res的值如下:

    android:textCursorDrawable="@drawable/red_cursor"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-22
      • 2017-10-31
      • 2012-02-24
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多