title: Draw horizontal line on bottom of drawable programmatically
body: <p>I have to change the divider color of my listView dynamically.    </p>
  
  <ol>
  <li><p>solution:<br>
  Therefore I to create a Drawable programmatically that draws a horizontal line and set it as background of my convertView. Now the line is in the middle of my convertView. How can I align it to the bottom?</p>
  
  <pre><code>public class DividerView extends Drawable {
  private Paint mPaint;
  
  public DividerView() {
      mPaint = new Paint();
      mPaint.setStrokeWidth(3);
  }
  
  @Override
  public void draw(Canvas canvas) {
      int lvl = getLevel();
      Rect b = getBounds();
      float x = b.width() * lvl / 10000.0f;
      float y = (b.height() - mPaint.getStrokeWidth()) / 2;
      mPaint.setColor(Color.BLACK);
      canvas.drawLine(x, y, b.width(), y, mPaint);
  }
  
  @Override
  protected boolean onLevelChange(int level) {
      invalidateSelf();
      return true;
  }
  
  @Override
  public void setAlpha(int alpha) {
  }
  
  @Override
  public void setColorFilter(ColorFilter cf) {
  }
  
  @Override
  public int getOpacity() {
      return PixelFormat.TRANSLUCENT;
  }
  }
  </code></pre></li>
  <li><p>solution:<br>
  I also tried to use a shape drawable as divider and change its color. But I get the following exception:</p>
  
  <pre><code>LayerDrawable cannot be cast to android.graphics.drawable.GradientDrawable
  </code></pre></li>
  </ol>
  
  <p>How can I access the stroke in my layer-list?<br>
  Here is my code:  </p>
  
  <p>divider.xml</p>
  
  <pre><code>&lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
  &lt;item&gt;
      &lt;shape android:shape="rectangle" &gt;
          &lt;solid android:color="@android:color/transparent" /&gt;
      &lt;/shape&gt;
  &lt;/item&gt;
  
  &lt;item android:top="-6dp" android:right="-6dp" android:left="-6dp"&gt;
      &lt;shape&gt;
          &lt;solid android:color="@android:color/transparent" /&gt;
          &lt;stroke
              android:width="1dp"
              android:color="#000000" /&gt;
      &lt;/shape&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p></p>
  
  <p>ListAdapter.java  </p>
  
  <pre><code>GradientDrawable drawable = (GradientDrawable)convertView.getBackground();
                      drawable.setStroke(3, Color.RED);
                      convertView.setBackground(drawable);
  </code></pre>