(有时)空白(红色)WebView

时间:2019-05-12 15:56:59

标签: android android-webview

在我的Android应用程序中,我将片段(android.support.v4.app.Fragment)与WebView一起使用,该片段可从后端服务器加载网站。它可以在99%的环境中正常工作,但有时我可以看到一个空白(红色)的Android WebView布局,如以下屏幕截图所示:https://i.stack.imgur.com/JQQio.png

有我的片段视图:

<?xml version="1.0" encoding="utf-8"?>

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="false"
android:clipToPadding="true"
android:focusable="false"
android:gravity="center_horizontal"
android:orientation="vertical">

<WebView
    android:id="@+id/webview"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:clipToPadding="false"
    app:layout_constraintBottom_toTopOf="@id/footer"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<View
    android:layout_width="0dp"
    android:layout_height="@dimen/compare_footer_shadow_height"
    android:background="@drawable/shadow_horizontal_top"
    app:layout_constraintBottom_toTopOf="@+id/footer"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent" />

<LinearLayout
    android:id="@+id/footer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:clipToPadding="true"
    android:gravity="center"
    android:orientation="horizontal"
    android:paddingBottom="@dimen/compare_footer_vertical_padding"
    android:paddingTop="@dimen/compare_footer_vertical_padding"
    android:visibility="visible"
    app:layout_constraintBottom_toBottomOf="parent">

    <View
        android:layout_width="@dimen/compare_footer_color_indicator_size"
        android:layout_height="@dimen/compare_footer_color_indicator_size"
        android:layout_margin="@dimen/compare_footer_color_indicator_margin"
        android:background="@drawable/bg_red_oval" />

    <TextView
        style="@style/DefaultText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="@dimen/compare_footer_button_horizontal_margin"
        android:text="@string/route_comparison_usual_route"
        android:textColor="@color/font_black" />

    <View
        android:layout_width="@dimen/compare_footer_color_indicator_size"
        android:layout_height="@dimen/compare_footer_color_indicator_size"
        android:layout_margin="@dimen/compare_footer_color_indicator_margin"
        android:background="@drawable/bg_green_oval" />

    <TextView
        style="@style/DefaultText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/route_comparison_better_route"
        android:textColor="@color/font_black" />

</LinearLayout>

<include
    layout="@layout/loading_overlay"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</android.support.constraint.ConstraintLayout>

0 个答案:

没有答案