title: Android. Change the background color of a FrameLayout from code
body: <p>I'm trying to change the background color of a FramyLayout.
  The color is changing, but to the wrong one.</p>
  
  <p>However it is working fine if I do it through the XML.</p>
  
  <p>Here is my res/values/colors.xml code</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
      &lt;color name="grey"&gt;#888888&lt;/color&gt;
      &lt;color name="white"&gt;#FFFFFF&lt;/color&gt;
      &lt;color name="red"&gt;#ffff3448&lt;/color&gt;
      &lt;color name="green"&gt;#ff408c3a&lt;/color&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>Here is how it looks like if I make changes in the XML
      
  <img src="https://i.stack.imgur.com/G0KVw.png" alt="Colors changed correctly"></p>
  
  <p>And that's what is happening if I try to do it with the code</p>
  
  <pre><code> FrameLayout frameLayoutBalance = (FrameLayout)view.findViewById(R.id.frameLayoutBalance);
   frameLayoutBalance.setBackgroundColor(R.color.green);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/5OCbP.png" alt="Colors changed incorrectly"></p>