解决方法
在XML中,它看起来像这样:
style="?header_background"
在程序上,这有点棘手.在你的活动中
private static Theme theme = null; protected void onCreate(Bundle savedInstanceState) { ... theme = getTheme(); ... } public static int getThemeColors(int attr){ TypedValue typedvalueattr = new TypedValue(); theme.resolveAttribute(attr,typedvalueattr,true); return typedvalueattr.resourceId; }
int outside_background = MyActivity.getThemeColors(R.attr.outside_background); setBackgroundColor(getResources().getColor(outside_background));
这有点复杂,但你去;-)