我只是在ConstraintLayout中设置我的webview。我无法在活动底部显示Banner。它始终覆盖操作栏。所有我想显示id第一个动作栏然后webview然后在底部横幅广告。 下图显示了当前的布局:
这是我的activity_browser.xml
@model Lab1.Models.FriendModel
@{
ViewBag.Title = "Edit";
}
<h2>Edit</h2>
@using (Html.BeginForm())
{
<label>Name</label><br />
<div>@Html.TextBoxFor(m => m.name)</div>
<label>Id</label><br />
<div>@Html.TextBoxFor(m => m.id)</div>
<label>Place</label><br />
<div>@Html.TextBoxFor(m => m.mesto)</div>
<br/>
@Html.LabelFor(m => m.pos)
<input id="Submit1" type="submit" value="Edit" />
}
这是content_browser_full.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true"
tools:context=".webBrowser.BrowserActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include
android:id="@+id/include"
layout="@layout/content_browser_full" />
<ProgressBar
android:id="@+id/progressBar"
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-7dp"
android:indeterminate="true"
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_ads"/>
</android.support.design.widget.CoordinatorLayout>
答案 0 :(得分:0)
我看不到ConstraintLayout
但只看到CoordinatorLayout
简单的方法是添加此行:
android:layout_gravity="bottom"
到AdView
。请记住,这也将在您的浏览器(WebView
)之上,但在屏幕的底部。如果它符合您的需要,请使用它,否则详细说明您的需求。
答案 1 :(得分:0)
也许您已经解决了,但是其他一些可以帮助您解决这个问题。
您需要添加以下代码
ads:layout_constraintBottom_toBottomOf="parent"
完整代码:
<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_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
android:layout_gravity="bottom"
ads:layout_constraintBottom_toBottomOf="parent"
ads:adUnitId="@string/banner_home_footer">
</com.google.android.gms.ads.AdView>