There is an activity with two elements:

  1. WebView (full screen).
  2. ProgressBar in the middle (hidden by default).

You need to add an AdView banner from Yandex down the screen. The height of the banner is not fixed (AdSize.flexibleSize ()), that is, the height of the webview should vary depending on the height of the adview.

How to do it?

enter image description here

Code:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:orientation="horizontal"> <WebView android:id="@+id/webView" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" /> <ProgressBar android:id="@+id/progressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:visibility="invisible" android:layout_centerVertical="true"/> <com.yandex.mobile.ads.AdView android:id="@+id/banner_view" android:layout_width="match_parent" android:layout_height="wrap_content"/> </RelativeLayout> 

    1 answer 1

    Items are in RelativeLayout

      <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@color/colorPrimary" android:id="@+id/img0" android:layout_above="@+id/img1"/> <ImageView android:id="@+id/img1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:src="@color/colorAccent" /> 

    Here the main parameter "layout_alignParentBottom" for the bottom element, which indicates its location in the bottom. And "layout_above" is for the top one, in which you specify the id of the view over which it is located.

    • Thanks. It works - user2168735