What's the Color code that Android:hint uses? By that I mean the grayish color.
-
What are you talk in about? What is your question? – M D Mar 11 '14 at 13:18
-
i think he want to know the exact color as an rgb hex string. – kai Mar 11 '14 at 13:19
-
@Kai Yes, The exact hex code that the hint is "made of". – Paramone Mar 11 '14 at 13:20
-
The exact color hex that stock android uses – kabuto178 Mar 11 '14 at 13:20
-
are you talking about this? http://developer.android.com/reference/android/widget/TextView.html#getHintTextColors%28%29 – donfuxx Mar 11 '14 at 13:23
8 Answers
R: 128
G: 128
B: 128
or
#808080

- 8,084
- 8
- 48
- 62

- 749
- 6
- 8
-
1The color which @lapadets provide is better matching the hint on my nexus 7, Android 5.1 – Gem Feb 17 '16 at 11:29
-
4#9E9E9E seems to be better matching in my device. #808080 is too dark, whereas #A8A8A8 is a bit lighter than the default hint color. The best option would be to use @Pomanh 's solution if the colour should match accurately. – Abhimanyu Jan 04 '20 at 16:08
try #a8a8a8 :)
Create a color.xml file in the res/value folder
Then define it like that:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="gray">#a8a8a8</color>
</resources>
Then use it like that:
android.graphics.Color.gray;

- 1,067
- 10
- 38
-
6Don't call it grey. Give it a name that represents the application of the color. Call it "hintColor" or something. – Mark Buikema Mar 11 '14 at 13:44
For getting hint color you can use getCurrentHintTextColor(). Then you need to transform int to hex format. For example:
EditText et = (EditText) findViewById(R.id.edit_text);
int c = et.getCurrentHintTextColor();
Log.d("Hint color", String.format("%X", c));

- 4,955
- 1
- 12
- 22
in sources, holo theme :
<color name="hint_foreground_holo_light">#808080</color>
<color name="hint_foreground_holo_dark">#808080</color>
Material theme:
<color name="foreground_material_dark">@android:color/white</color>
<item format="float" name="hint_alpha_material_dark" type="dimen">0.50</item>
<color name="foreground_material_light">@android:color/black</color>
<item format="float" name="hint_alpha_material_light" type="dimen">0.38</item>
so for light theme you can use #61000000 //black 38%
and for dark theme #80ffffff //white 50%

- 1,447
- 15
- 16
Best approach would be to feed in color values with R,G,B Channels. For gray,
R=127 (hex = 7F),
G=127 (hex = 7F),
B=127 (hex = 7F),
Hence, color-value = #7F7F7F -> go ahead and use this for gray color
OR, if you are lazy and dont want to do the above math - you can choose to use the inbuilt color options available. For example, in a simple TextView
android:textColor="@android:color/black"
There are more options, hitting Ctrl + Space after color/ will show the other possible options.
Hope this helps.

- 3,318
- 5
- 33
- 55
Create an adapter like this
class SpinnerAdapter(context: Context, items: List<String>) :
ArrayAdapter<String>(context, R.layout.spinner_item_layout, items) {
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View {
val spinnerItemView = super.getDropDownView(position, null, parent) as TextView
spinnerItemView.setBackgroundResource(R.drawable.light_gray_border_bottom_bg) // optional( here i am giving a style for spinner item)
if (position == 0) {
spinnerItemView.setTextColor(
ContextCompat.getColor(
context,
R.color.hintColor
)
)
} else {
spinnerItemView.setTextColor(ContextCompat.getColor(context, R.color.colorPrimaryText))
}
return spinnerItemView
}
override fun isEnabled(position: Int) = position != 0
}
And this is my spinner_item_layout
file
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:padding="10dp"
android:text="Spinner Text"
android:textColor="?android:textColorHint"
android:textSize="14sp"
android:includeFontPadding="false"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content"/>

- 1,735
- 3
- 11
- 28
In code:
It is android.R.color.tab_indicator_text
. You can get it by getResources().getColor(android.R.color.tab_indicator_text, null)
. Or you can get it from RGB: Color.rgb(128, 128, 128)
In xml:
Add this attribute: android:textColor="?android:textColorHint"
or android:textColor="#FF808080"

- 15
- 2
- 5