Follow

Advanced Usage - Adding a banner programmatically

View original article on our GitHub

You can add a banner programmatically, instead of using the layout XML.

For example, this is a basic example of adding a center-aligned banner to the bottom of the layout:

// Get the Main relative layout of the entire activity
RelativeLayout mainLayout = (RelativeLayout)findViewById(R.id.mainLayout);   
// Define StartApp Banner
Banner startAppBanner = new Banner(context);
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?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments