I hope the attached screenshot make my issue clear, The the last item in the RecyclerView
list is getting overlapped by the AdView
.
Adding bottom padding & margin to the RecyclerView
, leaves a blank space at the bottom behind the AdView
, this is undesirable.
Is there any way to set over-scroll or offset to the scrolling ?
Any quick solutions/suggestion would be helpful, Thanks in advance.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v7.widget.RecyclerView
android:id="@+id/rvProverbs"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:spanCount="4"
/>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/ad_unit_id">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
The height of banners with the attribute adSize="BANNER"
is 50 dp.
The simplest solution might be to add an 50 dp (or greater) bottom padding to your RecyclerView
and set clipToPadding
to false
:
<android.support.v7.widget.RecyclerView
android:id="@+id/rvProverbs"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="50dp"
android:clipToPadding="false"
app:spanCount="4" />
In case your AdView
has a dynamic height (or you would like to add the padding only when the AdView
is loaded), you just have to set the padding dynamically as well, from code.
For example:
adView.setAdListener(new AdListener() {
@Override
public void onAdLoaded() {
recyclerView.setPadding(0, 0, 0, adView.getHeight());
// recyclerView.setClipToPadding(false);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With