What is android default color for disabled text in edittext?
Asked Answered
C

2

6

I want to set hint color in EditText as disabled text color. So I am using android:textColorHint attribute. But I don't know how to do that:

android:textColorHint="@android:color/???"     // what should I select?
//OR
android:textColorHint="?android:attr/???"      // what should I select?

Edit: I can define the same color in values but I want to reference it to handle future changes.

Carpophore answered 16/11, 2014 at 7:14 Comment(1)
I know that its black with a lowered opacity, but for the sake of it I screenshot it and used the color picker tool in Photoshop and the shade seems to be #bdbdbd.Cosignatory
C
10

You can find answer in documentation
https://material.google.com/style/color.html#color-text-background-colors

For dark text on light backgrounds, apply the following opacity levels:

The most important text has an opacity of 87%.
Secondary text, which is lower in the visual hierarchy, has an opacity of 54%.
Text hints (like those in text fields and labels) and disabled text have even lower visual prominence with an opacity of 38%.

Concertize answered 21/9, 2016 at 14:12 Comment(3)
+1 for pointing out that the colour in disabled state is actually not a different colour (like grey), but the default colour (e.g. black) with a lowered opacity.Lilililia
This is black with 38% opacity: <color name="android_default_disabled">#61000000</color> it worked fine for me for disabled hint text colorTantalate
The design docs do say use alpha, but that incurs a performance penalty as mentioned in the Reduce Overdraw doc. Instead, it recommends finding the color without using transparency.Felske
N
5

Hello Misagh, You can get the hint color using following ways :

 1. final ColorStateList colors = editText.getHintTextColors();
     editText.setTextColor(colors);`
  1. Color code is : #808080 (R-128, G-128, B-128)

You can go through this documantation : http://developer.android.com/reference/android/widget/TextView.html#getHintTextColors%28%29

Please let me know , If having any problem.

Nierman answered 16/11, 2014 at 8:10 Comment(1)
Your solution in helpful, but actually not the answer. Because I want to change hint color to disable color, not changing disable color to hint color. However I am voting it up. Thanks.Carpophore

© 2022 - 2024 — McMap. All rights reserved.