title: Incremental Opacity, wanting constant opacity Image View with Drawable
body: <p>I am programmatically creating textviews with horizontal lines between each view. Using a drawable created programmatically.</p>
  
  <p>The problem is, the opacity starts off light and gradually increases for each line.</p>
  
  <p>I've logged the opacity (getAlpha()) of the drawable, paint, image view and linear layout at all the points in the two methods provided and from the drawables it's always 255 and the views 1.0. I don't understand why it's not behaving as though this is true. I've also tried setting Alpha, it makes no difference. </p>
  
  <p>Why is it doing this and how do I fix it?</p>
  
  <p>xml:</p>
  
  <pre><code>&lt;LinearLayout android:id="@+id/main"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" .../&gt;
  
      &lt;Button android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:onClick="PaintDashedLines"
          android:text="Press Me"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>java:</p>
  
  <pre><code>static int tvCount = 0;
  
  public void PaintDashedLines(View v) {
      LinearLayout ll = (LinearLayout) findViewById(R.id.main);
      TextView tv = new TextView(MainActivity.this);
      tv.setGravity(Gravity.CENTER);
      tv.setTextSize(25);
      tv.setPadding(0, 5, 0, 5);
      ll.addView(tv);
      tv.setText("TextView " + tvCount);
      ImageView divider = new ImageView(MainActivity.this);
      LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
              ll.getWidth(), 2);
      lp.setMargins(0, 5, 0, 5);
      divider.setLayoutParams(lp);
      divider.setBackground(CreateDashedLined());
      ll.addView(divider);
      tvCount++;
  }
  
  public static Drawable CreateDashedLined() {
      ShapeDrawable sd = new ShapeDrawable(new RectShape());
      Paint fgPaintSel = sd.getPaint();
      fgPaintSel.setColor(Color.BLACK);
      fgPaintSel.setStyle(Paint.Style.STROKE);
      fgPaintSel.setPathEffect(new DashPathEffect(new float[]{5, 10}, 0));
      return sd;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/3w1MX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3w1MX.png" alt="enter image description here"></a></p>