Skip to main content

Banner Placement

Banner placements display an anchored banner ad inline in your layout. In the direct integration the JS engine drives the banner height — set the container height to wrap_content and it resizes as the creative loads.


Sample App

The official Teads SDK sample application includes working examples of this format. Use it for implementation examples and as a reference while you set up this placement.

Teads Android Sample App on GitHub

Example​

<!-- res/layout/activity_main.xml -->
<FrameLayout
android:id="@+id/banner_container"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
import android.os.Bundle
import android.widget.FrameLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import tv.teads.sdk.combinedsdk.TeadsAdPlacementEventName
import tv.teads.sdk.combinedsdk.adplacement.TeadsAdPlacementBanner
import tv.teads.sdk.combinedsdk.adplacement.config.TeadsAdPlacementBannerConfig
import tv.teads.sdk.combinedsdk.adplacement.interfaces.TeadsAdPlacementEventsDelegate
import tv.teads.sdk.combinedsdk.adplacement.interfaces.core.TeadsAdPlacement

class BannerActivity : AppCompatActivity(), TeadsAdPlacementEventsDelegate {

private var banner: TeadsAdPlacementBanner? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

// 1. Build the placement configuration
val config = TeadsAdPlacementBannerConfig(
articleUrl = "https://yoursite.com/article".toUri(),
widgetId = "MB_10", // Provided by your Teads account manager
installationKey = "YOUR_INSTALLATION_KEY",
widgetIndex = 0
)

// 2. Create the placement and load the ad — context (this) MUST be an Activity
val placement = TeadsAdPlacementBanner(this, config, this)
banner = placement

// 3. Attach the returned view to your container
val adView = placement.loadAd()
findViewById<FrameLayout>(R.id.banner_container).addView(adView)
}

override fun onPlacementEvent(
placement: TeadsAdPlacement<*, *>,
event: TeadsAdPlacementEventName,
data: Map<String, Any>?
) {
// React to placement lifecycle events — see Placement Events Listener for the full event reference.
}
}

Best Practices​

Activity context

Use an Activity context to create TeadsAdPlacementBanner (not the application context). The SDK uses it to size the creative correctly. Passing the application context can cause the ad to be mis-sized.

Dynamic height

Keep the host container's height as wrap_content. A fixed height clips the ad because the JS engine resizes the view dynamically as the creative loads.

Do not open the click URL

The SDK opens the paid CLICKED URL. Do not navigate in that handler or the browser will open twice. Use it for tracking only. CLICKED_ORGANIC is publisher-owned — you still open that URL yourself.

Ad Lifecycle Listener​

Implement TeadsAdPlacementEventsDelegate to observe playback, clicks, and viewability. See Placement Events Listener for the full event reference and error handling guide.

Checklist​