0

I have a screen where i have 2 fullscreen views, and i want an adwhirl ad at the bottom.

Here is my xml file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="bottom"
    android:id="@+id/main_layout"
    >
</RelativeLayout>

Then i put the views on it from code:

    // in activity's onCreate 
    RelativeLayout layout = (RelativeLayout)findViewById(R.id.main_layout); 

    v1= new V1(this);
    v2= new V2(this, v1);

    RelativeLayout.LayoutParams  lp = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);

    v1.setLayoutParams(lp);
    v2.setLayoutParams(lp);

    layout.addView(v1);
    layout.addView(v2);

    .....
    AdWhirlLayout adWhirlLayout2 = new AdWhirlLayout(this, "key");
    adWhirlLayout2.setAdWhirlInterface(this);
    adWhirlLayout2.setMaxWidth(width);
    adWhirlLayout2.setMaxHeight(height);

    RelativeLayout.LayoutParams  lp_bottom = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    lp_bottom.addRule(RelativeLayout.ALIGN_BOTTOM, RelativeLayout.TRUE);
    adWhirlLayout2.setLayoutParams(lp_bottom);

    layout.addView(adWhirlLayout2);

But the ads are still at the top of the screen, like when i didn't set the layoutparams.

gberes
  • 1,169
  • 1
  • 12
  • 32

1 Answers1

0

Try :

lp_bottom.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
user
  • 86,916
  • 18
  • 197
  • 190