Kid*_*d24 42
例如,要获取名为MyTheme的主题的editTextColor属性值:
TypedArray a = getTheme().obtainStyledAttributes(
R.style.MyTheme,
new int[] { R.attr.editTextColor });
// Get color hex code (eg, #fff)
int intColor = a.getColor(0 /* index */, 0 /* defaultVal */);
String hexColor = Integer.toHexString(intColor);
// Don't forget to recycle
a.recycle();
Run Code Online (Sandbox Code Playgroud)