title: android shape xml rotated drawable change color programmatically
body: <p>This is a xml for triangle shape:</p>
  
  <pre><code>&lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt;
      &lt;item android:id="@+id/shape_id"&gt;
          &lt;rotate
              android:fromDegrees="45"
              android:toDegrees="45"
              android:pivotX="-40%"
              android:pivotY="87%" &gt;
              &lt;shape android:shape="rectangle" &gt;
                  &lt;stroke android:width="10dp"/&gt;
              &lt;/shape&gt;
          &lt;/rotate&gt;
      &lt;/item&gt;
  &lt;/layer-list&gt;
  </code></pre>
  
  <p>And this is a background of a textview</p>
  
  <pre><code>&lt;TextView
      android:id="@+id/headlineSelect_TXT2"
      android:layout_width="50dp"
      android:layout_height="50dp"
      android:layout_weight="1"
      android:background="@drawable/category_triangle_shape1"
      android:visibility="invisible" /&gt;
  </code></pre>
  
  <p>And I want to change color of shape programmatically. I tried this but I am getting null pointer exception</p>
  
  <pre><code>LayerDrawable bgDrawable = (LayerDrawable) getActivity()
      .getResources()
      .getDrawable(R.drawable.category_triangle_shape1);
  final GradientDrawable shape = (GradientDrawable) bgDrawable
      .findDrawableByLayerId(R.id.shape_id);
  shape.setStroke(10,Color.GREEN);
  </code></pre>
  
  <p>How can I do that? Thanks for help.</p>