When the default layout doesn't fit your design, you can provide a completely custom XML layout. You control every pixel — the SDK only handles data fetching, impression tracking, and click handling.
How It Works
You provide an implementation of MCNativeAdRenderer — an interface with two methods:
Method
What it does
getItemLayoutId()
Returns your custom XML layout resource for a single campaign card
onBindCampaign(View, MCCampaign, int)
Binds campaign data to your views — you decide what to show
The SDK handles everything else: fetching, scrolling, impression tracking, click handling.
The SDK inflates your layout for each campaign and calls onBindCampaign on the UI thread.
Here we present three different custom layout examples that you can use as an inspiration for your implementation. These are just examples, you can customize the layout however you'd like.
Example A: Circular Thumbnails
This example creates a horizontal scroll of campaigns with circular images, promo badges, in-progress indicators, and a currency icon.
Step A.1: Create the item layout
You'll also need these drawables:
res/drawable/bg_circle.xml — circular background for the image:
Note: The SDK bundles mc_bg_badge_promo and mc_bg_badge_progress drawables. You can reference them directly from your layouts using @drawable/mc_bg_badge_promo and @drawable/mc_bg_badge_progress.
Step A.2: Set the renderer
You can just copy-paste this code to try it out, but remember to replace https://my-cdn/my-coin-image.png with your actual icon:
Example B: Vertical Layout (small cards)
This example renders a vertical list of compact row cards. Each item shows a rounded thumbnail on the left, the title and an "In Progress" badge in the center, and the reward with currency icon on the right. The promo badge floats above the top-right corner of the card.
Step B.1: create the item layout
The mc_bg_badge_progress and mc_bg_badge_promo drawables are bundled with the SDK. bg_card and mc_bg_thumbnail are examples of your own drawables.
Step B.2: wire the renderer
Set the orientation to vertical and provide an MCNativeAdRenderer that inflates the layout above and binds each MCCampaign to its views. Also in this case, remember to replace https://your.cdn/currency.png with your actual currency icon.
Example C: Vertical Layout (big cards)
This example creates a vertical list of large cover cards. Each item shows a wide cover image at the top, and a full-width green reward pill at the bottom.
Step C.1: set the item layout
bg_cover_card, bg_cover_top, bg_reward_pill and bg_promo_badge_bordered are examples of your own drawables. mc_bg_badge_progress is bundled with the SDK.
Step C.2: wire the renderer
Remember to replace https://your.cdn/currency.png with your actual currency icon when copying this code.
Key Points for Custom Layouts
Click Handling
The SDK wires click handlers automatically — tapping any item opens the campaign's detail page. You can override this with setOnCampaignClickListener().
Image Loading
Use the SDK's built-in image loader in your renderer:
It handles background downloading, bitmap decoding, and RecyclerView recycling. No external library needed.
RecyclerView Recycling Tip
For horizonatl layouts, set android:minHeight on the root layout to ensure consistent item heights.