android中得到颜色,图片资源的方式

button01.setBackgroundColor(getResources().getColor(R.color.red));

color.xml

colors.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <color name="red">#f00</color>
    <color name="green">#0f0</color>
    <color name="blue">#00f</color>
    <color name="black">#000</color>
</resources>


你可能感兴趣的:(android)