Android TextView has height and width of 0
<p>I have a small project where I want to reuse a certain UI component a few time so I created a widget by expanding a ViewGroup. In that ViewGroup I inflated a view that contained a TextView inside a LinearLayout and added that inflated view to the ViewGroup trough addView.</p>

<p>The outer LinearLayout expands itself perfectly but the inner TextView have getHeight() = 0 and getWith() = 0 when I view it through Hierarchy Viewer. The strange thing is that layout_height and layout_width is the values I gave them in my xml.</p>

<p>I don't have the code here but it looked something like this:</p>

<p>xml:   </p>

<pre><code>&lt;LinearLayout  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"&gt;  

    &lt;TextView  
        android:text="random text.."  
        android:layout_with="200px"  
        android:layout_height="50px" /&gt;  
&lt;/LinearLayout&gt;  
</code></pre>

<p>Java:</p>

<pre><code>class MyWidget extends ViewGroup {
...

//In constructor  
myView = View.inflate(context, R.layout.xml, null);  
addView(myView);  

//In layout  
myView.layout(l, t, r, b);  
</code></pre>

<p>I have tried to give my text view fill_parent values for size but it didn't help.</p>
