yowovogu
yowovogu

Reputation: 3

Admob ad under a view

I want to add an admob ad under a view so it will be hided.

So admob still acts as it's showing ?

<view hidden>
    <com.google.android.gms.ads.AdView
                xmlns:ads="http://schemas.android.com/apk/res-auto"
                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="ca-app-pub-3940256099942544/6300978111">
</view>

https://developers.google.com/admob/android/quick-start

Upvotes: 0

Views: 40

Answers (1)

Russell Ghana
Russell Ghana

Reputation: 3113

you can use FrameLayout for laying views on top of each other, for example see below code :

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <View
        android:layout_width="120dp"
        android:layout_height="120dp"
        android:background="#000000"
        android:layout_gravity="center"
        android:id="@+id/hiddenView"
        />
    <View
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFFFF"
        android:id="@+id/topView"
        />
</FrameLayout>

in this layout the second view (the view with white background called topView) is on top, and first view (the view with black background called hiddenView) goes behind second view

Upvotes: 1

Related Questions