0

i am able to center my banner using gravity class, but i am not able to stretch my banner to occupy full width.

And also i tried smart_banner which supposed to fill according to the density, but with no success.

need help

RelativeLayout layout = (RelativeLayout)findViewById(R.id.ultimaterellayout);
 // Create the adView

    AdView adView = new AdView(MainActivity.this, AdSize.BANNER, "aaa324dsfdfsd");


    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    layout.setGravity(Gravity.CENTER_HORIZONTAL);
    layout.addView(adView, layoutParams);
    layout.invalidate();

  // layout.addView(adView);
   adView.loadAd(adRequest);
Nikolay Elenkov
  • 52,576
  • 10
  • 84
  • 84
Ajax -the Max
  • 1,049
  • 9
  • 20

1 Answers1

0

Try to set the width of RelativeLayout as fill_parent.

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
GrIsHu
  • 29,068
  • 10
  • 64
  • 102