【问题标题】:InApp-Browser: Actionbar overlaps WebView contentInApp-Browser:Actionbar 与 WebView 内容重叠
【发布时间】:2017-09-10 15:51:27
【问题描述】:

我的问题是操作栏与此处的任何 webview 内容重叠:

为了比较,它与 Instagram 徽标应该是这样的:https://www.instagram.com/about/us/


这是我的InAppBrowser 的activity_browser.xml 以打开外部webview 内容:

<?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"
    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=".InAppBrowser">

    <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="?attr/actionBarSize"
            android:background="?attr/colorPrimaryDark"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

    </android.support.design.widget.AppBarLayout>

    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <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" />

</android.support.design.widget.CoordinatorLayout>

Actionbar 与 webview 重叠,因此 webview 内容似乎从 Actionbar 开始的地方开始。

我尝试将AppBarLayoutWebViewProgressBar 包装在附加的RelativeLayout 中,但这也不起作用。

感谢任何建议。

【问题讨论】:

    标签: android android-layout webview android-actionbar


    【解决方案1】:

    我刚刚添加了

    android:layout_marginTop="?attr/actionBarSize"
    

    WebView,现在它在视觉上工作了,因为我将边距偏移设置为与操作栏相同的大小,但我认为这更像是一个hacky解决方案,所以我仍然欣赏其他解决方案/建议。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-17
      相关资源
      最近更新 更多