Android Admob广告不会以标签形式显示,并带有片段线性布局
我试图在我的屏幕底部实现广告,有人告诉我,我必须将linearlayout更改为RelativeLayout,但当我这样做时,我的工具栏不知怎么变小了,选项卡开始看起来很奇怪。因此,我认为可能有一些东西需要更改或添加到RelativeLayout,但我不知道下面是我的linearlayoutAndroid Admob广告不会以标签形式显示,并带有片段线性布局,android,admob,android-linearlayout,Android,Admob,Android Linearlayout,我试图在我的屏幕底部实现广告,有人告诉我,我必须将linearlayout更改为RelativeLayout,但当我这样做时,我的工具栏不知怎么变小了,选项卡开始看起来很奇怪。因此,我认为可能有一些东西需要更改或添加到RelativeLayout,但我不知道下面是我的linearlayout <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
tools:context="com.example.Jus.Forever.MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed"
android:background="@color/colorPrimary"/>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<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_footer">
</com.google.android.gms.ads.AdView>
</LinearLayout>
既然没有你想要的图像,我只能猜测。但这应该是可行的:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
tools:context="com.example.Jus.Forever.MainActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<android.support.design.widget.TabLayout
android:layout_below="@id/toolbar"
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed"
android:background="@color/colorPrimary"/>
<android.support.v4.view.ViewPager
android:layout_below="@id/tabs"
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<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="12345">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
您已告诉ViewPager使用整个屏幕 将其更改为:
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
是,这将解决问题,因为RelativeLayout最后一个元素将覆盖所有其他元素。下面的布局_将确定定位。