Search code examples
androidandroid-linearlayoutandroid-cardviewadview

Adview Banner at bottom of LinearLayout covers imagebuttons in Android


i want AdView to be displayed at the bottom of the screen but it hiding the imagebuttons, I set gravity as bottom as well as layout-gravity as bottom even-though there is no luck for me. Please help

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/grey">
    <TextView
        android:layout_width="wrap_content"
        android:textColor="@color/colorPrimaryDark"
        android:textSize="40dp"
        android:textStyle="bold"
        android:text="@string/end"
        android:layout_height="wrap_content"
        android:layout_gravity="center"/>
    <TextView
        android:layout_width="wrap_content"
        android:textColor="@color/colorPrimaryDark"
        android:textSize="18dp"
        android:textStyle="bold"
        android:text="@string/end2"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_marginTop="30dp"/>
    <com.mindorks.placeholderview.SwipePlaceHolderView
        android:id="@+id/swipeView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    <LinearLayout
        android:id="@+id/ll10"
        android:layout_alignParentTop="true"
        android:layout_above="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:gravity="center"
        android:orientation="horizontal" >
        <ImageButton
            android:id="@+id/rejectBtn"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:background="@drawable/ic_skip"/>
        <ImageButton
            android:id="@+id/viewBtn"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="50dp"
            android:background="@drawable/ic_view"/>
        <ImageButton
            android:id="@+id/acceptBtn"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_marginLeft="50dp"
            android:background="@drawable/ic_heart"/>
    </LinearLayout>
    <com.google.android.gms.ads.AdView
        android:id="@+id/adView02"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_below="@id/ll10"
        android:layout_centerHorizontal="true"
        android:layout_gravity="bottom"
        ads:adSize="SMART_BANNER"
        ads:adUnitId="@string/banner_ad_unit_id02">
    </com.google.android.gms.ads.AdView>
</FrameLayout>

Thanks in advance.


Solution

  • I just fix it by adding relativelayout:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
    <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>
    
     <com.google.android.gms.ads.AdView
            android:id="@+id/adView02"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="@string/banner_ad_unit_id"></com.google.android.gms.ads.AdView>
    
    </RelativeLayout>