title: How to show AdMob ads aligned to the right of the screen on Device
body: <p>I am trying to align Admob banner to right of the device screen. However It is not working for me. I am creating a banner like this</p>
  
  <pre><code>  RelativeLayout layout = new RelativeLayout(activity);
                  activity.addContentView(layout, new RelativeLayout.LayoutParams(
                          LayoutParams.MATCH_PARENT,
                          LayoutParams.MATCH_PARENT));
                  setLayout(layout, llType);
  </code></pre>
  
  <p>Here <code>setLayout</code> is called which set the layout of the banner depending upon the type</p>
  
  <pre><code>   private void setLayout(RelativeLayout layout, int type) {
      switch (type) {
          case AdLayoutType.Top:
              layout.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
              break;
          case AdLayoutType.Bottom:
              layout.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
              break;
          case AdLayoutType.Left:
              RelativeLayout.LayoutParams leftParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
              leftParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
              layout.setLayoutParams(leftParams);
               break;
          case AdLayoutType.Right:
  //This does not work as it gives Class cast exception
                  RelativeLayout.LayoutParams rightParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
                  rightParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
                  layout.setLayoutParams(rightParams);
               break;
              default:
                  break;
          }
  </code></pre>
  
  <p>Can somebody help me in this?
  Thanks
      }</p>