Android, RelativeLayout and dynamically adding elements
<p>I have an app where I would like to add a free version with ads, but I wanted to make minimal changes to my code.  So in my layout I did this:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout android:id="@+id/mainLayout"
android:layout_width="fill_parent" android:layout_height="0dip"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"&gt;

&lt;FrameLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/adFrameLayout" android:background="@android:color/white"&gt;

&lt;/FrameLayout&gt;
&lt;LinearLayout android:id="@+id/buttonGrp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"
    android:layout_below="@id/adFrameLayout" android:orientation="horizontal"&gt;
    &lt;Button android:id="@+id/normalGameBtn" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="@string/normalGame"/&gt;
    &lt;Button android:id="@+id/shareBtn" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:text="@string/shareButton"/&gt;
&lt;/LinearLayout&gt;

&lt;RadioGroup android:id="@+id/aiRadioGrp" android:layout_below="@id/buttonGrp"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:checkedButton="@+id/normalAI" android:layout_gravity="center_horizontal"&gt;
     ...
&lt;/RadioGroup&gt;
&lt;ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@id/aiRadioGrp"&gt;
    &lt;TextView android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:text="@string/description" android:textSize="16dip"
        /&gt;
&lt;/ScrollView&gt;
</code></pre>

<p></p>

<p>So what I want is that the FrameLayout (adFrameLayout) that is at the top I wanted it to show ads if it was the free version and if paid then size should stay at 0.</p>

<p>So in the base (pro) code I use Guice to inject an object that does extra processing in onCreate.  In the pro version the code does nothing, in the free version I am doing this:</p>

<pre><code>@Override
public void accept(Activity activity) {
    FrameLayout frame = (FrameLayout) activity.findViewById(R.id.adFrameLayout);
    frame.getLayoutParams().height = 20;
    frame.invalidate();
}
</code></pre>

<p>This is just an example to make sure it would work, which it does not, the FrameLayout stays at a size of 0.  How can I get it to resize in the code dynamically?  Of course if I specify 20px in the xml it works fine, but I would guess that in the paid version me trying to set the size to 0 won't work either.  What am I doing wrong?  </p>

<p>BTW I set the size right after I do the setContentView(R.id.main)</p>
