edittext中禁用文本的android默认颜色是什么?

Mis*_*rdi 3 android textcolor android-edittext

我想将提示颜色设置EditText为禁用的文本颜色.所以我使用android:textColorHint属性.但我不知道该怎么做:

android:textColorHint="@android:color/???"     // what should I select?
//OR
android:textColorHint="?android:attr/???"      // what should I select?
Run Code Online (Sandbox Code Playgroud)

编辑:我可以在值中定义相同的颜色,但我想引用它来处理未来的更改.

Dim*_*ima 6

您可以在文档https://material.google.com/style/color.html#color-text-background-colors中找到答案

对于浅色背景上的深色文本,请应用以下不透明度级别:

最重要的文字的不透明度为87%.
次要文本在视觉层次结构中较低,不透明度为54%.
文本提示(如文本字段和标签中的文本提示)和禁用的文本具有更低的视觉突出度,不透明度为38%.


小智 5

您好 Misagh,您可以通过以下方式获取提示颜色:

 1. final ColorStateList colors = editText.getHintTextColors();
     editText.setTextColor(colors);`
Run Code Online (Sandbox Code Playgroud)
  1. 颜色代码为:#808080(R-128、G-128、B-128)

你可以通过这个文档: http : //developer.android.com/reference/android/widget/TextView.html#getHintTextColors%28%29

请让我知道,如果有任何问题。

  • 您的解决方案有帮助,但实际上不是答案。因为我想更改提示颜色以禁用颜色,而不是将禁用颜色更改为提示颜色。不过,我投票赞成。谢谢。 (3认同)