首页 > 解决方案 > 如何将广告拉到底部?

问题描述

我想知道广告到底是怎样的。我将在下面给你一些例子。如果你知道给我答案。

 <?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"
    android:id="@+id/main_content"
    android:layout_width="match_parent"
    android:layout_height="match_parent">




    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/navigation">

        <androidx.coordinatorlayout.widget.CoordinatorLayout
            android:id="@+id/tab_coordinator_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true">

            <com.google.android.material.appbar.AppBarLayout
                android:id="@+id/tab_appbar_layout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:theme="@style/AppTheme.AppBarOverlay">

                <include
                    android:id="@+id/toolbar"
                    layout="@layout/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?actionBarSize"
                    app:layout_scrollFlags="scroll|enterAlways" />

            </com.google.android.material.appbar.AppBarLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior">

                <com.duolingo.open.rtlviewpager.RtlViewPager
                    android:id="@+id/viewpager_rtl"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior" />

                <androidx.viewpager.widget.ViewPager
                    android:id="@+id/viewpager"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

            </RelativeLayout>

        </androidx.coordinatorlayout.widget.CoordinatorLayout>

    </RelativeLayout>

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="?android:attr/windowBackground"
        app:menu="@menu/navigation" />
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/navigation">

        <com.startapp.sdk.ads.banner.banner3d.Banner3D
            android:id="@+id/startAppBanner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"/>
    </RelativeLayout>
</RelativeLayout>

在此处输入图像描述

试了几天,发现什么都修复不了

标签: android

解决方案


只需添加 linear_layout 并将底部导航和横幅广告视图放入其中。

试试下面的代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/layAdsBottom">

    <androidx.coordinatorlayout.widget.CoordinatorLayout
        android:id="@+id/tab_coordinator_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fitsSystemWindows="true">

        <com.google.android.material.appbar.AppBarLayout
            android:id="@+id/tab_appbar_layout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/AppTheme.AppBarOverlay">

            <include
                android:id="@+id/toolbar"
                layout="@layout/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?actionBarSize"
                app:layout_scrollFlags="scroll|enterAlways" />

        </com.google.android.material.appbar.AppBarLayout>

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior">

            <com.duolingo.open.rtlviewpager.RtlViewPager
                android:id="@+id/viewpager_rtl"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                app:layout_behavior="@string/appbar_scrolling_view_behavior" />

            <androidx.viewpager.widget.ViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </RelativeLayout>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</RelativeLayout>

<LinearLayout
    android:id="@+id/layAdsBottom"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical">

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="?android:attr/windowBackground"
        app:menu="@menu/navigation" />

    <com.startapp.sdk.ads.banner.banner3d.Banner3D
        android:id="@+id/startAppBanner"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true" />

</LinearLayout>

推荐阅读