2011-07-09 31 views

回答

3

使用@android:color/primary_text_dark_nodisableandroid:color/secondary_text_dark_nodisable作为文本视图的文本颜色。您可以在XML做到这一点无论:

<TextView 
    android:textColor="@android:color/secondary_text_dark_nodisable" 
/> 

或编程:

textView.setTextColor(activity.getResources().getColor(android.R.color.primary_text_dark_nodisable)); 
+0

[资源#的getColor(http://developer.android.com/reference/android/content/res/Resources。 html#getColor%28int%29)仅返回来自复杂[ColorStateList](http://developer.android.com/reference/android/content/res/ColorStateList.html)的默认颜色。所以在给定的例子中,如果使用primary_text_dark或primary_text_dark_nodisable,则无关紧要。为了得到ColorStateList,你应该使用[Resources#getColorStateList](http://developer.android.com/reference/android/content/res/Resources.html#getColorStateList%28int%29)。 – devconsole