Created
January 12, 2022 18:23
-
-
Save ahmmedrejowan/87165fa3435a335df0407d8e03e47d7e to your computer and use it in GitHub Desktop.
Adview Not Overlapping MainViews
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
sorry brother doesn't reserve any space for banner ad
but I solved this problem by manually.
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:background="?attr/bgColorForMyApp"
app:layout_constraintBottom_toTopOf="@+id/ad_view_linear_layout_at_word_meaning_activity_db"
app:layout_constraintTop_toTopOf="parent">
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/notification_for_word_with_db"
android:text="Please read or add more wordModuleEnglishToBangleForEnBnSqlite from date of published !"
android:textAppearance="@style/TextAppearance.AppCompat.Display2"
android:textColor="?attr/textColorForMyApp"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_view_word_meaning_with_db"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="?attr/bgColorForMyApp"
android:divider="@color/material_light_yellow_50"
android:dividerHeight="4dp"
android:fadingEdgeLength="1dp"
android:footerDividersEnabled="true"
android:headerDividersEnabled="true"
android:overScrollFooter="@color/material_light_yellow_50"
android:overScrollHeader="@color/material_light_yellow_50"
android:scrollbars="vertical">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/ad_view_linear_layout_at_word_meaning_activity_db"
android:background="?attr/bannerAdViewBgColor"
android:visibility="visible"
android:layout_gravity="bottom"
app:layout_constraintBottom_toBottomOf="parent"
android:paddingBottom="5dp"
android:orientation="horizontal"
android:paddingTop="10dp"
>
<Space
android:layout_width="wrap_content"
android:layout_height="51dp"
android:id="@+id/spaceForAdview_db"
/>
<com.google.android.gms.ads.AdView
android:id="@+id/ad_view_banner_at_word_meaning_activity_db"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_at_word_meaning_activity_ad_unit_id" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
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
These two items are the thing that makes the thing work.