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>


原文地址:https://www.cnblogs.com/tianzhijiexian/p/3852664.html