Add admob after a Listview in a Relativelayout

Asked

Viewed 67 times

1

Goodnight!

I’m trying to add an admob to the end of a Listview in a Relativelayout and the banner doesn’t appear at all! I’ve tried several different ways in the layout to see if Listview wasn’t covering admob, but it didn’t solve anything. Could someone help me?

Follow the xml below:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="16dp"
    android:paddingLeft="64dp"
    android:paddingRight="64dp"
    android:paddingTop="16dp"
    android:background="@drawable/background"
    xmlns:ads="http://schemas.android.com/apk/res-auto">

    <com.google.android.gms.ads.AdView
        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="@string/banner_ad_unit_id">
    </com.google.android.gms.ads.AdView>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:text="Suas Faltas"
        android:textColor="@color/white"
        android:textStyle="bold"
        android:textSize="25sp"
        android:layout_alignParentTop="true"
        android:id="@+id/textView2" />

    <ListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_below="@+id/textView2"
        android:layout_alignParentStart="true"
        android:layout_marginTop="15dp" />

    <TextView android:id="@+id/vazio"
        android:text="Nenhuma matéria inserida"
        android:textColor="@color/white"
        android:layout_below="@+id/textView2"
        android:layout_alignParentStart="true"
        android:layout_marginTop="15dp"
        android:gravity="center"
        android:ems="10"
        android:layout_width="244dp"
        android:layout_height="42dp"/>


</RelativeLayout>

1 answer

0

Try using a LinearLayout, see if this solution helps you.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    android:orientation="vertical"
    android:paddingBottom="16dp"
    android:paddingLeft="64dp"
    android:paddingRight="64dp"
    android:paddingTop="16dp">


    <TextView
        android:id="@+id/textView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="5dp"
        android:text="Suas Faltas"
        android:textColor="#ffffff"
        android:textSize="25sp"
        android:textStyle="bold" />

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:gravity="center"
        android:layout_weight="1">

        <ListView
            android:id="@+id/list"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_alignParentStart="true"
            android:layout_marginTop="15dp" />

        <TextView
            android:id="@+id/vazio"
            android:layout_width="244dp"
            android:layout_height="42dp"
            android:layout_alignParentStart="true"
            android:layout_marginTop="15dp"
            android:ems="10"
            android:gravity="center"
            android:text="Nenhuma matéria inserida"
            android:textColor="#ffffff" />

    </RelativeLayout>

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id"/>


</LinearLayout>
  • It did not work, besides not appearing the adview, disorganized the presentation of listview :(

Browser other questions tagged

You are not signed in. Login or sign up in order to post.