McHiggey
McHiggey

Reputation: 1

How to add a margin or padding above and below banner ad

I'd like to add a small margin above and below my banner ad. What is the best way to do so, please?

My code:

<androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/cont" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:orientation="vertical" app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            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"
                android:layout_gravity="center"
                android:visibility="gone"
                ads:adSize="FULL_WIDTHx50"

                ads:adUnitId="@string/admobid"
                app:layout_behavior="@string/appbar_scrolling_view_behavior" />

            <com.google.android.material.bottomnavigation.BottomNavigationView
                android:id="@+id/bottomnavigation"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"

                android:layout_gravity="bottom"
                android:background="@color/white"
                android:theme="@style/Theme.AppCompat.DayNight"
                android:visibility="gone"

                app:itemIconTint="@drawable/bottombar_properties"
                app:itemTextAppearanceActive="@style/BottomNavigationView.Active"
                app:itemTextAppearanceInactive="@style/BottomNavigationView.Inactive"

                app:itemTextColor="@drawable/bottombar_properties"
                app:labelVisibilityMode="labeled"
                app:layout_behavior="@string/appbar_scrolling_view_behavior"
                app:menu="@menu/bottomnav_menu" />
        </LinearLayout>

    </androidx.coordinatorlayout.widget.CoordinatorLayout>

    <include layout="@layout/url_bar" />


</RelativeLayout>

I've tried adding via Design view but this failed as the banner is hidden by default and it all goes wrong if I try to unhide it.

Upvotes: 0

Views: 187

Answers (2)

McHiggey
McHiggey

Reputation: 1

I resolved this issue by adding:

<View
    android:layout_width="match_parent"
    android:layout_height="16dp" 
    android:background="@android:color/holo_red_dark" />

above <com.google.android.gms.ads.AdView

Thanks everyone for the help.

Upvotes: 0

IODevBlue
IODevBlue

Reputation: 91

Use the android:layout_marginTop to add a margin above the banner ad and android:layout_marginBottom for bottom margin.

Upvotes: 0

Related Questions