AppBrain Best Android Apps
AppBrain | Docs
  • Apps
  • Statistics
  • Docs
  • Developers
  • Get SDK
  • Sign up
  • Log in

General

  • Introduction
  • Privacy policy
  • About AppBrain
  • HTML widgets
  • Embeddable Android app widgets

Publishers

  • AppBrain SDK
    • Getting started
    • Ad unit overview
    • Banners
    • Interstitial
    • ListView ads
    • Extra features
    • Integration with other SDKs
    • Integration policy
    • Javadoc
  • Resources
  • Terms of service
  • FAQ

Advertisers

  • Resources
  • Terms of service
  • FAQ

Intelligence

  • Insights
  • Subscriptions
  • SDK downloads
  • Phone downloads
  • Terms of service

AppBrain API

  • Using the AppBrain API
  • API specification
  • Pricing
  • Promotion campaigns
  • Reporting
  • AppLinks TOS
Search

Banners

Adding a banner

../_images/banner.png

The AppBrain SDK allows you to put industry-standard banners into your app. In a layout XML file, you can add a banner to your app using the following code:

<com.appbrain.AppBrainBanner
    android:layout_width="match_parent"
    android:layout_height="wrap_content" />

Programmatically

If you would like to add a banner to your layout without using XML, you can instantiate the banner programmatically using the following code:

import com.appbrain.AppBrainBanner;

public void addBanner(ViewGroup parent) {
    AppBrainBanner banner = new AppBrainBanner(getContext());
    parent.addView(banner);
}

AppBrain banners are by default responsive, meaning that their size is increased on larger screens, which leads to better monetization. This behavior can be changed using AppBrainBanner.setSize().

To use AppBrain banners in mediation solutions like Admob or MoPub, see the section about integration with other SDKs.

AdId

If you use multiple banners in your app, you may like to get separate ad reports on the developer dashboard. To do this each banner needs its own AdId. To set an AdId in your XML, you need to define the AppBrain namespace in your view. Then you can set the adid attribute like so:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:appbrain="http://schemas.android.com/apk/lib/com.appbrain"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <!-- Other views -->

    <com.appbrain.AppBrainBanner
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        appbrain:adid="home_screen"/>
</LinearLayout>

The value of appbrain:adid can be any of the predefined AdId constants, or a custom AdId value you create on the developer dashboard. For more information see the AdId javadoc.

More apps

  • Top Android apps being viewed
  • UNiTV for Android
  • UniTV IPTV Player
  • Paradise Wallpapers

Android Statistics

  • Android statistics
  • Google Play Developer stats
  • Trending Android Apps
  • Top popular Apps

About AppBrain

  • Contact
  • Blog
  • Privacy
  • Documentation
  • Articles
  • Free App-Ads.Txt Validation
© 2010-2024 - AppBrain