android - 进度条和 webview 问题

标签 android android-layout webview progress-bar

当我将 Relative Layout 替换为 Linear Layout 时,我的 webview 占据了整个屏幕,包括工具栏,但 progress bar 有效很好 AND 当我使用 Linear Layout 时,我的 web view 在工具栏下方开始,但它不显示进度条

我的 webview 应该从工具栏下方开始,中间有一个进度条。 帮我解决这个问题

XML

<LinearLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".activities.MyWebView">

<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/wbtoolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:contentInsetLeft="0dp"
        app:contentInsetStart="0dp"
        app:popupTheme="@style/AppTheme.PopupOverlay">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

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

<ProgressBar
    android:id="@+id/progressBar"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true" />

最佳答案

试试用 RelativeLayout

替换您的 LinearLayout
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".Activities.MenuButtonActivity">


    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/AppTheme.AppBarOverlay">
        <android.support.v7.widget.Toolbar
            android:id="@+id/wbtoolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:contentInsetLeft="0dp"
            app:contentInsetStart="0dp"
            app:popupTheme="@style/AppTheme.PopupOverlay">
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"/>
        </android.support.v7.widget.Toolbar>
    </android.support.design.widget.AppBarLayout>
    <WebView
        android:id="@+id/web_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/appbar" />

    <ProgressBar
        android:id="@+id/progressBar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />


</RelativeLayout>

关于android - 进度条和 webview 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52380181/

相关文章:

android - 使用 opencv for android 绘制火柴

android - Amazon S3 TransferUtility 在应用程序关闭时停止,即使在 WorkManager 中也是如此

android - 我如何在Android的Text To Speech类中找到印度口音

android - 使用水平和垂直平移/拖动和捏缩放查看

java - Android:其他人可以从 apk 文件中或安装后看到其中的 Java 代码和字符串(例如 WebView 的 Javascript 命令)吗?

android - 如何杀死一个应用程序的所有 Activity ?

java - 我一直在尝试在 map 下面获取底部表格,但收到错误,我不知道它来自哪里

android - ImageButton 背景自动切换? Drawables 变得疯狂了吗?

android - 我的 webview 视频不断加载,如何播放?

javascript - 绕过WebView跨域安全