title: How rotate line in Android XML?
body: <p>I'm trying to draw a diagonal line in an Android app with the XML, but it is not working. It simply draws a horizontal line.</p>
  
  <p><strong>main.xml</strong>:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".TestActivity" &gt;
  
      &lt;RelativeLayout
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true" 
          style="@style/diagonalStyle"&gt;
      &lt;/RelativeLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>styles.xml</strong>:</p>
  
  <pre><code>&lt;resources xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;style name="diagonalStyle"&gt;
          &lt;item name="android:background"&gt;@drawable/background&lt;/item&gt;
      &lt;/style&gt;
  
  &lt;/resources&gt;
  </code></pre>
  
  <p><strong>background.xml</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  
      &lt;item&gt;
          &lt;rotate
              android:fromDegrees="0"
              android:toDegrees="45"
              android:pivotX="50%"
              android:pivotY="50%" &gt;
              &lt;shape
                  android:shape="line"
                  android:top="1dip" &gt;
                  &lt;stroke
                      android:width="1dip"
                      android:color="#FF0000" /&gt;
              &lt;/shape&gt;
          &lt;/rotate&gt;
      &lt;/item&gt;
  
  &lt;/layer-list&gt;
  </code></pre>