title: Error while trying to set custom shape as background of widget
body: <p>I want to set the background of the standard <code>TextView</code> in an Android project to a custom shape. The shape is defined as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"
         android:shape="rectangle" &gt;
  
      &lt;gradient android:type="radial"
                android:angle="90"
                android:startColor="#FF1EFFFF"
                android:endColor="#B01E90FF"
                android:centerColor="#201E90FF"
                android:centerX="0.5"
                android:centerY="1.0" /&gt;
  
  &lt;/shape&gt;
  </code></pre>
  
  <p>I try to set the custom shape by calling the <code>setBackgroundResource()</code> method on the textView.</p>
  
  <pre><code>TextView main = (TextView) findViewById(R.id.mainTextView);
  main.setBackgroundResource(R.drawable.gradient);
  </code></pre>
  
  <p>However, when I deploy this project on either a real device or on the Android Emulator, it won't start, and show this error:</p>
  
  <p><code>ERROR/AndroidRuntime(4369): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.android.gradienttest/org.android.gradienttest.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class &lt;unknown&gt;</code></p>
  
  <p>Trying to set the drawable by first getting it as a shape results in the same error.
  By getting it as a shape I mean:</p>
  
  <pre><code>Resources res = getResources();
  Shape shape = res.getDrawable(R.drawable.gradient);
  </code></pre>
  
  <p>But as I said, this results in the same error... I know it gives the error when I try to load the shape, but the problem is I don't know why... So could anybody give me some help on this one? It must be a trivial mistake, as there isn't that much code involved...</p>