How to size android layout dynamically
<p>I need to size the top-most layout of my application dynamically (programmatically) based on information loaded from a configuration file.</p>

<p>Right now the in main.xml I have </p>

<pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; 
    &lt;LinearLayout   
            android:id="@+id/LinearLayout01" 
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent" 
            xmlns:android="http://schemas.android.com/apk/res/android" 
            android:background="@drawable/background"&gt;
    &lt;/LinearLayout&gt;
</code></pre>

<p>So I am looking for a way to change android:layout_width and layout_height programmatically.</p>

<p>Any help would be appreciated</p>

<p>RM</p>

<p>EDIT:</p>

<p>As per suggestions I have tried the following:</p>

<pre><code>LinearLayout l2 = (LinearLayout)findViewById(R.id.LinearLayout07);
LinearLayout.LayoutParams params =  new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT,1);
l2.setLayoutParams(params);
</code></pre>

<p>But that gives me the following error when running:</p>

<pre><code>Thread [&lt;3&gt; main] (Suspended (exception ClassCastException))    
FrameLayout.onLayout(boolean, int, int, int, int) line: 288 
FrameLayout(View).layout(int, int, int, int) line: 6133 
....
</code></pre>
