title: Linear Gradient not being displayed in some Android devices
body: <p>I am creating a gradient using <code>LinearGradient</code> on a <code>Canvas</code> object. I am using this gradient by including the class in my main layout XML.</p>
  
  <p>The code for generating the gradient is:</p>
  
  <pre><code>public class BackgroundGradient extends View{
  
      private Resources res;
      private int [] colors;
      private float [] pos;
      private Paint paint;
      private Shader shader;
  
      public BackgroundGradient(Context context) {
          // TODO Auto-generated constructor stub
          super(context);
          init();
      }
  
      public BackgroundGradient(Context context, AttributeSet attrs) {
          // TODO Auto-generated constructor stub
          super(context,attrs);
          init();
      }
  
      public BackgroundGradient(Context context, AttributeSet attrs, int defStyle) {
          // TODO Auto-generated constructor stub
          super(context,attrs,defStyle);
          init();
      }
  
      private void init() {
          paint  = new Paint();
          res    = getResources();
          colors = new int[10];
          pos    = new float[10];
  
          int[] c = { //array of colors };
  
          float[] p = { //positions };
  
          for (int i = 0; i &lt; 8; i++) {
              colors[i] = c[i];
              pos[i]    = p[i];
          }
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
          // TODO Auto-generated method stub
          super.onDraw(canvas);
  
          shader = new LinearGradient(0,getHeight(),getWidth(), 0, colors, pos, Shader.TileMode.CLAMP);
          paint.setShader(shader); 
          canvas.rotate(20, 0, getHeight());
          canvas.drawPaint(paint);
      }
  }
  </code></pre>
  
  <p>So, above is the file that I included in my <code>activity_main.xml</code> inside a <code>FrameLayout</code>.</p>
  
  <p><strong>activity_main.xml</strong>:</p>
  
  <pre><code>&lt;FrameLayout
      android:id="@+id/content_frame"
      android:layout_width="match_parent"
      android:layout_height="match_parent" &gt;
  
      &lt;include layout="@layout/bg_gradient" /&gt;
  
      &lt;LinearLayout 
          android:layout_width="match_parent"
          android:layout_height="5dp"
          android:background="#000"
          android:orientation="horizontal"&gt;
  
          &lt;TextView android:id="@+id/pager_strip"
              android:layout_width="100dp"
              android:layout_height="5dp"
              android:background="@color/mu_blue_6"/&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;!-- other views --&gt;  
  
  &lt;/FrameLayout&gt;
  </code></pre>
  
  <p><strong>bg_gradient.xml</strong>:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;merge xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;FrameLayout 
          android:layout_width="match_parent"
          android:layout_height="match_parent" &gt;
  
          &lt;!-- 
          &lt;Button
              android:layout_width="fill_parent" 
              android:layout_height="wrap_content"
              android:textColor="#000000"
              android:text="This is button" /&gt;  --&gt;  
  
          &lt;in.mubpack.b2o.ui.BackgroundGradient
              xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
      &lt;/FrameLayout&gt;
  &lt;/merge&gt;
  </code></pre>
  
  <p>I cannot figure out why the gradient is visible in some Android devices and not in others. Can anyone help me?</p>