Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AdView attached to bottom doesn't let me see last item in Recyclerview

I have a RelativeLayout in wich I have a RecyclerView and a LinearLayout with an AdView inside. The RecyclerView has many items and when I was unable to show them in the screen I just had to scroll down to see them, but now that I added the LinearLayout attached to the bottom of the screen with the AdView inside I scroll down and I'm not able to see the last item of the RecyclerView. I'm attaching the LinearLayout to the bottom but it seems that It's above the RecyclerView and I want the RecyclerView to show items in the screen but not behind the LinearLayout. Is it possible?

Here's my XML for the Layout:

<?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"
xmlns:ads="http://schemas.android.com/apk/res-auto">

<android.support.v7.widget.RecyclerView
    android:id="@+id/rvGeneric"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:gravity="center">

    <com.google.android.gms.ads.AdView
        android:id="@+id/adViewBaseRefresh"
        android:layout_width="fill_parent"
        android:layout_height="53dp"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id"
        android:layout_marginBottom="3dp">
    </com.google.android.gms.ads.AdView>

</LinearLayout>

like image 833
Nahue Avatar asked Jun 30 '16 18:06

Nahue


1 Answers

A relative layout needs "Relative" relationships defined within the XML. As you don't have any (other than align the linear layout on the bottom), the result is the LL and RecyclerView are overlapping.

Add the line android:layout_below="@id/rvGeneric" to the linear layout

<?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"
    xmlns:ads="http://schemas.android.com/apk/res-auto">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/ll_ad"
        android:layout_alignParentBottom="true"
        android:gravity="center">

        <com.google.android.gms.ads.AdView
             android:id="@+id/adViewBaseRefresh"
             android:layout_width="fill_parent"
             android:layout_height="53dp"
             ads:adSize="BANNER"
             ads:adUnitId="@string/banner_ad_unit_id"
             android:layout_marginBottom="3dp">
        </com.google.android.gms.ads.AdView>

    </LinearLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rvGeneric"
        android:layout_above="@id/ll_ad"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"/>

</RelativeLayout>
like image 78
FishStix Avatar answered Oct 20 '22 19:10

FishStix