Position button on top of ad

2

Hello, I'd like to know how I put a close ad button in the corner of the screen above the ad.

asked by anonymous 04.12.2016 / 02:51

1 answer

2

Use relative layout to group the closing bottom and ad. When the user clicks close you changes the relative layout to GONE visibility.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/adsContainer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.xxxxxxxxxx.android.MainActivity"
    android:padding="0dp"
    android:orientation="vertical"
    android:weightSum="1"
    android:background="#2c3e50">
    <FrameLayout
        android:id="@+id/frameLayout"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">
        <ProgressBar
            style="?android:attr/progressBarStyleLarge"
            android:id="@+id/progress"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:visibility="invisible"
            android:indeterminate="false" />
        <WebView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/webview"
            android:visibility="invisible"/>
    </FrameLayout>
    <LinearLayout
        android:id="@+id/frameAds"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation=“vertical”>
    <Button
            android:id="@+id/closeAd"
            android:background="@android:drawable/ic_menu_close_clear_cancel"
            android:layout_gravity="end"
            android:layout_width="25dp"
            android:layout_height="25dp"
            ads:backgroundTint="@android:drawable/screen_background_dark_transparent"
            android:visibility="visible" />
        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ads:adSize="SMART_BANNER"
            ads:adUnitId="@string/ID_ANUNCIO_BANNER"/>          
    </LinearLayout>
</LinearLayout>
    
04.12.2016 / 14:03