First, your RelativeLayout needs an identifier if you want to reference it:
RelativeLayout rLayout = (RelativeLayout)findViewById(R.id.yourRelativeId);
Then create some LayoutParams objects for the object (in this case, your admob adview) that tell it to align to the bottom (and not be tied to any other views, so it doesn't get squeezed out of the screen or not other types of moves):
RelativeLayout.LayoutParams rLParams = new RelativeLayout.LayoutParams( LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT); rLParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);
Then add the view to your RelativeLayout using LayoutParams:
rLayout.addView(yourAdView, rLParams);
source share