0
layout = new RelativeLayout(this);
        surface = new SurfaceView(this);
        ads = new AdView(this);
        ads.setAdSize(AdSize.SMART_BANNER);
        ads.setAdUnitId("admob banner ID");
        Ads.loadAds(ads);

        layout.addView(surface);

         RelativeLayout.LayoutParams adParams = 
         new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, 
         RelativeLayout.LayoutParams.WRAP_CONTENT);
         adParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);


        layout.addView(ads, adParams);

        setContentView(layout);
        holder = surface.getHolder();

here s the problem. I tried above code to integrate banner but it is covering portion od my app and hides some buttons. what can be the problem here? need help. please note that i am not using XML layout.

saad awan
  • 1
  • 1

1 Answers1

0

Since your surface and adView have no relationship, they will be rendered without considering each other's draw space.

Add this:

adParams.addRule(RelativeLayout.BELOW, surface.getId());

You also need to generate an id for the surface view. You can refer to this post to do that: https://stackoverflow.com/a/15442898/2977237

Community
  • 1
  • 1
tachyonflux
  • 20,103
  • 7
  • 48
  • 67