0

I'm trying to add a View to a Layout and put the View at the bottom of the screen. here is my code

RelativeLayout game = new RelativeLayout(this);
game.addView(new Menu(this));
game.addView(ad.getAd());
game.setGravity(Gravity.BOTTOM);
setContentView(game);  

But the View gets printed on the top of the screen, why isnt setGravity working?

user1104939
  • 1,395
  • 2
  • 13
  • 25

1 Answers1

0

Gravity don't works in RelativeLayout.

Try this:

RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(null);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, -1);
Menu menu = new Menu();
menu.setLayoutParams(params);
ad.getAd().setLayoutParams(params);
game.addView(menu);
game.addView(ad.getAd());
Roman Black
  • 3,501
  • 1
  • 22
  • 31