Skip to content

Instantly share code, notes, and snippets.

@ahmmedrejowan
Created January 12, 2022 18:23
Show Gist options
  • Save ahmmedrejowan/87165fa3435a335df0407d8e03e47d7e to your computer and use it in GitHub Desktop.
Save ahmmedrejowan/87165fa3435a335df0407d8e03e47d7e to your computer and use it in GitHub Desktop.
Adview Not Overlapping MainViews
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/adView"
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- All Other Layout and files-->
</LinearLayout>
</ScrollView>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111"/>
</RelativeLayout>
@ahmmedrejowan
Copy link
Author

ahmmedrejowan commented Jan 14, 2022

The main idea is to reserve space for the ad layout. Relative layout makes it easier. Put everything in a parent layout inside scroll view and put the scrollview above the adlayout. That's it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment