【问题标题】:how to change the color of the edittext text selection handles?如何更改edittext文本选择句柄的颜色?
【发布时间】:2016-09-18 12:24:58
【问题描述】:

我知道这个问题已经得到解答,但我找不到有效的解决方案。

在 android 上 > lolipop (21) 是否有任何方法可以更改我的文本选择句柄的颜色(无需上传新的 png 图像)?

我定义了这种风格

<?xml version="1.0" encoding="utf-8"?>
<resources>

  <style name="AppEditTextStyle" parent="@android:style/Widget.Material.Light.EditText">
    <item name="android:background">@null</item>    
    <item name="android:textCursorDrawable">@null</item> 
    <item name="android:drawableTint">#00ffffff</item>           
  </style>

  <style name="AppTheme" parent="@android:style/Theme.Material.Light.NoActionBar"> 
    <item name="android:editTextStyle">@style/AppEditTextStyle</item>
  </style>

</resources>

但这不起作用,我收到: 错误:找不到与给定名称匹配的资源:attr 'android:drawableTint'。

但在文档 (https://developer.android.com/reference/android/widget/TextView.html#attr_android:drawableTint) 中明确指出存在 android:drawableTint :( 所以我不明白为什么我想念?

【问题讨论】:

标签: android android-edittext android-theme android-styles


【解决方案1】:

在 android lolipop 和后来的手柄颜色是强调色。

我建议阅读以下内容:

Selection - Patterns - Material design guidelines

这是样式行:

<item name="colorAccent">@color/colorAccent</item>

并像这样设置选择颜色:

android:textColorHighlight="@color/colorAccent"

【讨论】:

  • 但是当我这样做时 @color/colorAccent 我收到没有找到与给定名称匹配的资源:attr 'colorAccent' :(
  • 我们能否将 @color/colorAccent 仅添加到一个 TextEdit 而不是全局定义它?
  • colorAccent for 句柄只有在 Activity 的主题中设置时才有效
猜你喜欢
  • 2023-03-17
  • 1970-01-01
  • 2013-02-14
  • 2020-10-02
  • 2021-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多