How can I set the width, the height, the pixels left and the pixels top of a admob android ad banner? I tied to use this code:
RelativeLayout layout = (RelativeLayout) findViewById(R.id.optionslayout);
adView = new AdView(this, AdSize.BANNER, "...ID...");
layout.addView(adView);
adView.setTop(layout.getHeight()/2 - adView.getHeight()/2);
adView.setLeft((int) (100*density));
adView.loadAd(new AdRequest());
But when I try to run this Activity it stops unexpectedly. Is there any solution for this problem? I also tried setX() and setY()!
Thank you!
define adView in Layout xml, and set these params there only.
and in your activity do this
adView = (AdView) findViewByID(R.id.adX);instead of