'How to show Applovin/Max Banner Ad with layout?
I am new to Applovin/Max. In their documentation position and size of Banner ad set by programmatically.
Thats why BannerAd override my app's content.
Banner layout in xml
<com.applovin.mediation.ads.MaxAdView
android:id="@+id/maxBannerAdLayout"
android:background="@color/white"
android:layout_width="match_parent"
android:layout_height="@dimen/banner_height" />
In documentation banner show progrmatically
adView = new MaxAdView( "YOUR_AD_UNIT_ID", this );
adView.setListener( this );
// Stretch to the width of the screen for banners to be fully functional
int width = ViewGroup.LayoutParams.MATCH_PARENT;
// Get the adaptive banner height.
int heightDp = MaxAdFormat.BANNER.getAdaptiveSize( this ).getHeight();
int heightPx = AppLovinSdkUtils.dpToPx( this, heightDp );
adView.setLayoutParams( new FrameLayout.LayoutParams( width, heightPx ) );
adView.setExtraParameter( "adaptive_banner", "true" );
// Set background or background color for banners to be fully functional
adView.setBackgroundColor( ... );
ViewGroup rootView = findViewById( android.R.id.content );
rootView.addView( adView );
// Load the ad
adView.loadAd();
I have no idea,
How can I connect code with banner layout?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
