我可以使用重力级来展示我的横幅,但是我无法将横幅拉伸到占据整个宽度。
而且我也尝试过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);
答案 0 :(得分:0)
尝试将RelativeLayout的宽度设置为fill_parent。
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);