How can I get a gradient from resource file in a canvas (custom view)?
<p>In an custom extended View (this is "class myView extends View") i'm trying to draw a gradient rectangle such as this:</p>

<pre><code>Paint p = new Paint();
p.setShader(new LinearGradient(0, 0, 0, getHeight(), Color.BLACK,Color.WHITE, Shader.TileMode.MIRROR));
canvas.drawPaint(p);
</code></pre>

<p>But loading the gradient from XML resource file.
I'm trying to get it by using:</p>

<pre><code>Drawable gradient = (Drawable) getResources().getDrawable(R.drawable.backgroundgradient);
</code></pre>

<p>But then I don't know the way to set the Paint shader to the gradient loaded from resources (can't cast).</p>

<p>How can I use the gradient to paint the canvas background?</p>
