Follow

Adding a Banner With Java Code Instead of XML

If you would like to add our banner to your layout using Java instead of XML, you are able to.  

 

This is a basic example of adding our banner with Java code (bottom of the layout, center aligned):

 

           

            // Get the Main relative layout of the entire activity
            RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id.mainLayout);   
// Define StartApp Banner
           Banner startAppBanner = new Banner(this);
            RelativeLayout.LayoutParams bannerParameters =
                        new RelativeLayout.LayoutParams(
                                    RelativeLayout.LayoutParams.WRAP_CONTENT,
                                    RelativeLayout.LayoutParams.WRAP_CONTENT);
            bannerParameters.addRule(RelativeLayout.CENTER_HORIZONTAL);
            bannerParameters.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);    
// Add to main Layout
            mainLayout.addView(startAppBanner, bannerParameters);
Was this article helpful?
8 out of 8 found this helpful
Have more questions? Submit a request

Comments