在所有活动中显示一个持续的admob广告横幅

时间:2014-03-13 12:58:30

标签: java android admob

我正在开发一个Android应用程序,我在每个活动的底部嵌入了admob广告,并在所有活动中显示广告,但我想在所有显示所有时间而不会破坏的活动中显示一个持续的admob广告在切换活动期间,请帮助我,如果有人知道这个问题的解决方案,我有3个活动,我也尝试创建一个基类,并使用这个基类扩展所有活动,并调用创建和加载广告的功能,但仍然是同样的问题,我必须从每个活动类调用此功能,所以每次它发送加载广告的请求并显示它所调用的欲望活动,我需要在所有三个活动上显示一个广告,thanx提前......

3 个答案:

答案 0 :(得分:1)

没有办法做到这一点。 正如埃利斯所说,您只想展示用户花费大部分时间的广告。

答案 1 :(得分:1)

可能有一种方法可以做到这一点。但为此,您可能需要完全重构您的应用UI。您可以在应用中保留一个活动,并将所有实际活动转换为片段。然后,您将只在相同的单个活动中交换片段。 我不建议这样做。

答案 2 :(得分:0)

不确定这是否对您有所帮助。试试这段代码吧。此外,如果需要,请尝试使用子片段方法查看寻呼机。

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <android.support.v4.widget.DrawerLayout
        android:id="@+id/drawer"
        android:layout_width="match_parent"
        android:fitsSystemWindows="true"
        android:layout_height="match_parent"
        android:layout_marginBottom="50dp">

        <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"
    android:orientation="vertical">


            <include android:id="@+id/toolbar_actionbar"     layout="@layout/toolbar_default"
                android:layout_width="match_parent" android:layout_height="wrap_content" />

            <FrameLayout android:id="@+id/container21" android:layout_width="match_parent"
                android:clickable="true" android:layout_height="match_parent" />
        </LinearLayout>

        < com.myapp.isgreat.ScrimInsetsFrameLayout android:id="@+id/scrimInsetsFrameLayout"
            android:layout_width="@dimen/navigation_drawer_width" android:layout_height="wrap_content"
            android:fitsSystemWindows="true" android:layout_gravity="start" app:insetForeground="#4000"
            android:elevation="10dp">
            <fragment android:id="@+id/fragment_drawer"
                android:name="com.my.appisgreat.NavigationDrawerFragment"
                android:layout_width="@dimen/navigation_drawer_width"
                android:layout_height="match_parent" android:fitsSystemWindows="true"
                app:layout="@layout/fragment_navigation_drawer"
                tools:layout="@layout/fragment_navigation_drawer" />
        </com.myapp.isgreat.ScrimInsetsFrameLayout>


    </android.support.v4.widget.DrawerLayout>
    <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>

    </RelativeLayout>

希望这会有所帮助..! 快乐的Android开发。!

相关问题