0

我可以使用重力类将横幅居中,但我无法拉伸横幅以占据整个宽度。

我也尝试了 smart_banner 应该根据密度填充,但没有成功。

需要帮忙

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);
4

1 回答 1

0

尝试将RelativeLayout的宽度设置为fill_parent。

RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
于 2013-01-28T08:48:15.107 回答