title: my Custom View gets drawn only when added in onCreate
body: <p>I made a "GraphBar" custom view that is a <code>RelativeLayout</code> with a <code>TextView</code> on the bottom and an <code>ImageView</code>, varying in height, above that. Here is the code:</p>
  
  <pre><code>public class GraphBar extends RelativeLayout {
  
      private int mAvailHeight; // space for the bar (component minus label)
      private float mBarHeight; // 0.0-1.0 value
  
      public GraphBar(Context context) {
          this(context, null);
      }
  
      public GraphBar(Context context, AttributeSet attrs) {
          this(context, attrs, 0);
      }
  
      public GraphBar(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
          LayoutInflater.from(context).inflate(R.layout.graphbar, this, true);
          setId(R.id.graphBar); // defined in &lt;merge&gt; but not assigned (?)
      }
  
      @Override
      protected void onSizeChanged(int w, int h, int oldw, int oldh) {
          super.onSizeChanged(w, h, oldw, oldh);
          mAvailHeight = getHeight()-findViewById(R.id.label).getHeight();
      }
  
      @Override
      protected void onLayout(boolean changed, int l, int t, int r, int b) {
          super.onLayout(changed, l, t, r, b);
  
          View bar2 = findViewById(R.id.smallBar);
          RelativeLayout.LayoutParams llp2 = (RelativeLayout.LayoutParams) bar2.getLayoutParams();
          llp2.height = Math.round((float)mAvailHeight * mBarHeight);
      }
  
      public void setBarHeight(float value, float max) {
          mBarHeight = value / max;
          findViewById(R.id.smallBar).requestLayout();
      }
  
      public void setLabel(CharSequence c) {
          ((TextView) findViewById(R.id.label)).setText(c);
      }
  }
  </code></pre>
  
  <p>While adding these GraphBars and setting their height in <code>onCreate()</code> works well, if I create them onClickSomething or call again <code>setBarHeight()</code> on the created bars, the only way to see changes is Load View Hierarchy. I've been told <a href="https://stackoverflow.com/q/4150446/503900">here</a> that it means I need to call somewhere <code>requestLayout()</code>. Where else than after modifying <code>mBarHeight</code>? Any help? I tried everywhere, and with <code>invalidate()</code> too.</p>
  
  <p>Thank you,
  Andrea</p>
  
  <p>(if you need I can post the activity with which i do my tests and the graphbar.xml)</p>
  
  <hr>
  
  <p>I've found it's probably <a href="http://code.google.com/p/android/issues/detail?id=6089" rel="nofollow noreferrer">a bug</a>. The workaround should be, again, calling <code>requestLayout()</code>. Still i don't understand where i can put the call.</p>