Android 将adMob横幅放置在内部视图中
我试图让广告看起来像是应用程序的一部分,把它们放在一个带有自定义背景的视图中。这是我想要实现的结果-实际上这是布局编辑器的预览: 但是,当我运行应用程序时,不会显示背景和“赞助”文本。我怎样才能让它工作 这是视图的当前布局:Android 将adMob横幅放置在内部视图中,android,admob,Android,Admob,我试图让广告看起来像是应用程序的一部分,把它们放在一个带有自定义背景的视图中。这是我想要实现的结果-实际上这是布局编辑器的预览: 但是,当我运行应用程序时,不会显示背景和“赞助”文本。我怎样才能让它工作 这是视图的当前布局: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto"
<LinearLayout 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="wrap_content"
android:orientation="vertical">
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="@string/admob_id"
ads:adSize="MEDIUM_RECTANGLE"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sponsorized"
/>
</LinearLayout>
创建另一个内部
线性布局
作为AdView
的父级。用这个
<LinearLayout 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="wrap_content"
android:orientation="vertical"
android:layout_margin="10dp"
android:background="@color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp">
<com.google.android.gms.ads.AdView android:id="@+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adUnitId="@string/admob_id"
ads:adSize="MEDIUM_RECTANGLE"/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sponsorized"/>
</LinearLayout>