Java Android 提示的颜色代码是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22326885/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What's the Color code for Android Hint?
提问by Paramone
What's the Color code that Android:hint uses? By that I mean the grayish color.
Android:hint 使用的颜色代码是什么?我的意思是灰色。
采纳答案by ottse
R: 128
G: 128
B: 128
or
或者
#808080
#808080
回答by lapadets
try #a8a8a8 :)
试试#a8a8a8 :)
Create a color.xmlfile in the res/value folder
在 res/value 文件夹中创建一个color.xml文件
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;
回答by sudhishkr
Best approach would be to feed in color values with R,G,B Channels. For gray,
最好的方法是使用 R、G、B 通道输入颜色值。对于灰色,
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
或者,如果您很懒惰并且不想进行上述数学运算 - 您可以选择使用可用的内置颜色选项。例如,在一个简单的 TextView
android:textColor="@android:color/black"
There are more options, hitting Ctrl + Spaceafter color/will show the other possible options.
还有更多选项,在color/之后按 Ctrl + Space将显示其他可能的选项。
Hope this helps.
希望这可以帮助。
回答by QArea
For getting hint color you can use getCurrentHintTextColor(). Then you need to transform int to hex format. For example:
要获得提示颜色,您可以使用 getCurrentHintTextColor()。然后你需要将 int 转换为十六进制格式。例如:
EditText et = (EditText) findViewById(R.id.edit_text);
int c = et.getCurrentHintTextColor();
Log.d("Hint color", String.format("%X", c));
回答by Pomanh
in your xml use this:
在你的 xml 中使用这个:
android:textColor="?android:textColorHint"
回答by scottymack
Looks like the default color is:
看起来默认颜色是:
#33000000
回答by John
in sources, holo theme :
在来源中,holo 主题:
<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%
所以对于浅色主题,您可以使用 #61000000 //black 38%
and for dark theme #80ffffff //white 50%
和黑暗主题 #80ffffff //white 50%