title: Android: Change Shape Color in runtime
body: <p>I have a drawable that i use as a Background for a LinearLayout. I would like to change the color of this Shape in runtime. I have tried using several methods.. but none work.</p>
  
  <p>I've followed the approach described here: <a href="http://www.anddev.org/android-2d-3d-graphics-opengl-problems-f55/change-shape-drawable-solid-color-t16798.html">http://www.anddev.org/android-2d-3d-graphics-opengl-problems-f55/change-shape-drawable-solid-color-t16798.html</a></p>
  
  <p>But have the same problem... it doesnt crashes.. but the color doesnt change!</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;solid android:color="#00A6C1" /&gt;
      &lt;corners android:radius="@dimen/square_corners" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>Snippet of code:</p>
  
  <pre><code>GradientDrawable drawable = (GradientDrawable) activity.getResources().getDrawable(R.drawable.blue_square_shape);
  
  
  int color = ((Application) getApplication()).getColor();
  drawable.setColor(color);
  
  block.findViewById(R.id.blockSquare).setBackgroundDrawable(drawable);
  
  findViewById(R.id.blockSquare).postInvalidate();
  </code></pre>
  
  <p>Any clue? I've passed the whole day googling... and it's getting pretty annoying...</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>When i try to do the same to this Shape:</p>
  
  <pre><code>&lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/shape" android:shape="rectangle"&gt;
      &lt;gradient android:startColor="#1FBCCF" android:endColor="#06A4C1"
          android:angle="270" /&gt;
      &lt;corners android:topLeftRadius="@dimen/footer_corners"
          android:topRightRadius="@dimen/footer_corners" /&gt;
  &lt;/shape&gt;
  </code></pre>
  
  <p>The color turns to black... what i guess tells it can be changed...</p>