Show banner AdView below transparent toolbar

329 views Asked by At

I have a the below layout: A customVideoView that displays a video,a transparent toolbar is positioned on top and a banner addview. I want the banner addview to appear below the transparent toolbar. However it currently shows under the toolbar, its visible but not clickable. Current layout view

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clipChildren="false"
android:id="@+id/frame"
tools:context="com.kelele.movies.Kelele_Home" >

<com.kelele.movies.util.CustomVideoView
    android:id="@+id/video"
    android:clickable="false"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:fitsSystemWindows="true"   />

<com.google.android.gms.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitId="@string/banner_ad_unit_id"
    android:layout_gravity="center_horizontal" />

<include
    android:id="@+id/transparent_toolbar"
    layout="@layout/toolbar" />

<ImageView
    android:id="@+id/video_play_btn"
    android:layout_width="100dp"
    android:layout_height="100dp"
    android:visibility="gone"
    android:src="@drawable/play"
    android:layout_gravity="center" />

1

There are 1 answers

0
S-MILE-S On

you can use WindowsManager.addView().

it probably look like this:

WindowManager.LayoutParams params=new WindowManager.LayoutParams();
params.type = WindowManager.LayoutParams.TYPE_PHONE;
            params.format = PixelFormat.RGBA_8888; 
            params.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
                    | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                    | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                    | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
            params.width = WindowManager.LayoutParams.FILL_PARENT;
            params.height = WindowManager.LayoutParams.WRAP_CONTENT;
            params.gravity = Gravity.CENTER_HORIZONTAL | Gravity.TOP;
windowManager= (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
windowManager.addview(new Banner(),params);