Android 如何使用户关闭横幅广告?

Android 如何使用户关闭横幅广告?,android,admob,ads,Android,Admob,Ads,我看过这篇文章 最近我下载了一个应用程序。在应用程序的左上角有一个关闭广告的X按钮。我如何实现该功能 这就是我的代码的外观 <RelativeLayout xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/

我看过这篇文章

最近我下载了一个应用程序。在应用程序的左上角有一个关闭广告的X按钮。我如何实现该功能

这就是我的代码的外观

<RelativeLayout xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    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=".MainActivity" >

    <!-- Header -->

    <TextView
        android:id="@+id/Header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#0585C2"
        android:textSize="16sp"
        android:textStyle="bold" />

    <!-- Expandable list characteristics -->

    <ExpandableListView
        android:id="@+id/expandable_list"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:childDivider="@android:color/white"
        android:divider="@android:color/darker_gray"
        android:dividerHeight="2dp"
        android:fadingEdge="none" />

    <com.google.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="a1523adgakdggak"
        ads:loadAdOnCreate="true"
        ads:testDevices="TEST_EMULATOR,022b1ahhddlkahda" />

</RelativeLayout>


--经过几天的研究,终于发现我们不能用xml实现,而且只有一些特定的广告网络提供关闭(x)功能。基本上我使用的是广告移动…所以现在我们不能添加x按钮(或者admob不提供该功能)…让我们希望..将来admob使我们能够使用该功能..:)…

您可以添加一个按钮并切换AdView的可见性,这可以产生相同的效果。就像:

closeBtn.setOnClickListener(new OnClickListener(View v){
            if (mAdView.getVisibility() == View.VISIBLE) {
                mAdView.setVisibility(View.GONE);
            } else {
                mAdView.setVisibility(View.VISIBLE);
            }
 });