Adding Admob Ads at the Top of your screen

Below is the code to display add at the bottom of your main Screen


@Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  
  setContentView(R.layout.welcome);  
 
  // Create an ad.
     adView = new AdView(this);
     adView.setAdSize(AdSize.SMART_BANNER);     
     adView.setAdUnitId(AD_UNIT_ID);
     
     // Add the AdView to the view hierarchy. The view will have no size
     // until the ad is loaded.
     RelativeLayout layout = (RelativeLayout) findViewById(R.id.welcome);
     layout.addView(adView);
     
     RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) adView.getLayoutParams();  
     params.addRule(RelativeLayout.ALIGN_PARENT_TOP, RelativeLayout.TRUE);
    adView.setLayoutParams(params);
     
     AdRequest adRequest = new AdRequest.Builder()
        //.addTestDevice(AdRequest.DEVICE_ID_EMULATOR) ===>Comment when you running in your actual device
      //  .addTestDevice("INSERT_YOUR_HASHED_DEVICE_ID_HERE")
        .build();
  
     // Start loading the ad in the background.
     adView.loadAd(adRequest);