Android 系统 Webview 更新后的 Android WebView 渲染问题

标签 android html android-webview rendering

Android 系统 WebView 更新后,我在 Android 设备上遇到 Webview 渲染问题。 Webview 在屏幕外呈现。有关更多信息,请查看屏幕截图。

enter image description here

有人遇到同样的问题吗?

如有任何帮助,我们将不胜感激。在此先致谢。

请按要求查看xml文件:

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar" />


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/fragment_back_color">


    <ScrollView
        android:id="@+id/offerDetailScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:layout_above="@+id/installTextView">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp">

            <android.support.v7.widget.CardView
                android:id="@+id/card_offer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:id="@+id/topViewDealDisplay"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/white"
                        android:gravity="center"
                        android:orientation="vertical"
                        android:paddingBottom="10dp"
                        android:paddingTop="10dp">

                        <ImageView
                            android:id="@+id/dealImageView"
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:layout_centerInParent="true"
                            android:layout_margin="5dp"></ImageView>


                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/dealNameTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:padding="4dp"
                            android:text=""
                            android:textColor="@color/text_color"
                            android:textSize="18sp" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/offerTitleTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:padding="4dp"
                            android:text="deal titile"
                            android:textColor="@color/lower_text_color"
                            android:textSize="18sp"
                            android:visibility="gone" />


                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/offerTypeTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:ellipsize="end"
                            android:gravity="center"
                            android:maxLines="2"
                            android:text=""
                            android:textColor="@color/lower_text_color"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <FrameLayout
                        android:id="@+id/frameLayoutAmount"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginTop="20dp"
                        android:clickable="true"
                        android:focusable="true"
                        android:gravity="right">

                        <ImageView
                            android:id="@+id/iv_rupee_bg"
                            android:layout_width="70dp"
                            android:layout_height="30dp"
                            android:layout_marginRight="-15dp"
                            android:background="@drawable/deals_image_background" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/tv_amount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:gravity="center"
                            android:paddingLeft="4dp"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="#ffffff"
                            android:textSize="17sp" />
                    </FrameLayout>
                </RelativeLayout>
            </android.support.v7.widget.CardView>


            <android.support.v7.widget.CardView
                android:id="@+id/cardview_descImage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/card_offer"
                android:layout_marginTop="10dp"
                android:paddingBottom="5dp"
                android:paddingTop="5dp">


                <ImageView
                    android:id="@+id/dealDescriptionImageView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:src="@null"
                    android:visibility="visible" />
            </android.support.v7.widget.CardView>


            <android.support.v7.widget.CardView
                android:id="@+id/cardview_shortDesc"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/cardview_descImage"
                android:layout_marginTop="10dp"
                android:padding="5dp">


                <WebView
                    android:id="@+id/shortDescWebView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:visibility="visible" />
            </android.support.v7.widget.CardView>


            <com.spiceladdoo.views.LatoBoldTextView
                android:id="@+id/related_offer_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/cardview_shortDesc"
                android:layout_gravity="center"
                android:layout_marginRight="10dp"

                android:text="SIMILAR OFFERS"
                android:textColor="@color/text_color"
                android:textSize="13sp" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerViewoffers"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_below="@id/related_offer_text"
                android:layout_marginTop="10dp"
                android:scrollbars="none" />

            <ProgressBar
                android:id="@+id/shortDescriptionProgress"
                style="?android:attr/android:progressBarStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:visibility="visible" />

        </RelativeLayout>
    </ScrollView>

    <com.spiceladdoo.views.LatoRegularTextView
        android:id="@+id/installTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:layout_marginTop="5dp"
        android:background="@color/newFreeBColor"
        android:gravity="center"
        android:paddingBottom="15dp"
        android:paddingTop="15dp"
        android:text="INSTALL"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#FFFFFF"
        android:textSize="16sp"
        android:textStyle="bold"
        android:visibility="visible" />


    <FrameLayout
        android:id="@+id/hint"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/layoutInstallHint"
                android:background="#99000000"></RelativeLayout>

            <RelativeLayout
                android:id="@+id/layoutInstallHint"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerInParent="true"
                android:background="#99000000">

                <com.spiceladdoo.views.LatoRegularTextView
                    android:id="@+id/installTextHint"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_marginBottom="15dp"
                    android:layout_marginTop="5dp"
                    android:background="@color/spice_laddooblue"
                    android:paddingBottom="10dp"
                    android:paddingLeft="80dp"
                    android:paddingRight="80dp"
                    android:paddingTop="10dp"
                    android:text="INSTALL"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="#FFFFFF"
                    android:textSize="15sp"
                    android:textStyle="bold"
                    android:visibility="visible" />
            </RelativeLayout>

            <com.spiceladdoo.views.LatoRegularTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_above="@+id/imageViewHintPinIcon"
                android:layout_centerHorizontal="true"
                android:text="Click on Button"
                android:textColor="@color/white"
                android:textSize="18sp" />

            <ImageView
                android:id="@+id/imageViewHintPinIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="50dp"
                android:src="@drawable/hint_pin_down" />
        </RelativeLayout>
    </FrameLayout>

</RelativeLayout>

最佳答案

我认为您在给 webview 的高度时犯了错误,您将其作为 wrap_content 而不是尝试 match_parent 并尝试

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">


<include
    android:id="@+id/toolbar"
    layout="@layout/toolbar" />


<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/fragment_back_color">


    <ScrollView
        android:id="@+id/offerDetailScrollView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:fillViewport="true"
        android:layout_above="@+id/installTextView">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="10dp">

            <android.support.v7.widget.CardView
                android:id="@+id/card_offer"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

                <RelativeLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content">

                    <LinearLayout
                        android:id="@+id/topViewDealDisplay"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:background="@color/white"
                        android:gravity="center"
                        android:orientation="vertical"
                        android:paddingBottom="10dp"
                        android:paddingTop="10dp">

                        <ImageView
                            android:id="@+id/dealImageView"
                            android:layout_width="45dp"
                            android:layout_height="45dp"
                            android:layout_centerInParent="true"
                            android:layout_margin="5dp"></ImageView>


                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/dealNameTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:padding="4dp"
                            android:text=""
                            android:textColor="@color/text_color"
                            android:textSize="18sp" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/offerTitleTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:padding="4dp"
                            android:text="deal titile"
                            android:textColor="@color/lower_text_color"
                            android:textSize="18sp"
                            android:visibility="gone" />


                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/offerTypeTextView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="10dp"
                            android:layout_marginRight="10dp"
                            android:ellipsize="end"
                            android:gravity="center"
                            android:maxLines="2"
                            android:text=""
                            android:textColor="@color/lower_text_color"
                            android:textSize="14sp" />
                    </LinearLayout>

                    <FrameLayout
                        android:id="@+id/frameLayoutAmount"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentTop="true"
                        android:layout_marginTop="20dp"
                        android:clickable="true"
                        android:focusable="true"
                        android:gravity="right">

                        <ImageView
                            android:id="@+id/iv_rupee_bg"
                            android:layout_width="70dp"
                            android:layout_height="30dp"
                            android:layout_marginRight="-15dp"
                            android:background="@drawable/deals_image_background" />

                        <com.spiceladdoo.views.LatoRegularTextView
                            android:id="@+id/tv_amount"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:gravity="center"
                            android:paddingLeft="4dp"
                            android:textAppearance="?android:attr/textAppearanceMedium"
                            android:textColor="#ffffff"
                            android:textSize="17sp" />
                    </FrameLayout>
                </RelativeLayout>
            </android.support.v7.widget.CardView>


            <android.support.v7.widget.CardView
                android:id="@+id/cardview_descImage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/card_offer"
                android:layout_marginTop="10dp"
                android:paddingBottom="5dp"
                android:paddingTop="5dp">


                <ImageView
                    android:id="@+id/dealDescriptionImageView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:adjustViewBounds="true"
                    android:src="@null"
                    android:visibility="visible" />
            </android.support.v7.widget.CardView>


            <android.support.v7.widget.CardView
                android:id="@+id/cardview_shortDesc"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/cardview_descImage"
                android:layout_marginTop="10dp"
                android:padding="5dp">


                <WebView
                    android:id="@+id/shortDescWebView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:visibility="visible" />
            </android.support.v7.widget.CardView>


            <com.spiceladdoo.views.LatoBoldTextView
                android:id="@+id/related_offer_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/cardview_shortDesc"
                android:layout_gravity="center"
                android:layout_marginRight="10dp"

                android:text="SIMILAR OFFERS"
                android:textColor="@color/text_color"
                android:textSize="13sp" />

            <android.support.v7.widget.RecyclerView
                android:id="@+id/recyclerViewoffers"
                android:layout_width="match_parent"
                android:layout_height="100dp"
                android:layout_below="@id/related_offer_text"
                android:layout_marginTop="10dp"
                android:scrollbars="none" />

            <ProgressBar
                android:id="@+id/shortDescriptionProgress"
                style="?android:attr/android:progressBarStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:visibility="visible" />

        </RelativeLayout>
    </ScrollView>

    <com.spiceladdoo.views.LatoRegularTextView
        android:id="@+id/installTextView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerInParent="true"
        android:layout_marginTop="5dp"
        android:background="@color/newFreeBColor"
        android:gravity="center"
        android:paddingBottom="15dp"
        android:paddingTop="15dp"
        android:text="INSTALL"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#FFFFFF"
        android:textSize="16sp"
        android:textStyle="bold"
        android:visibility="visible" />


    <FrameLayout
        android:id="@+id/hint"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:visibility="gone">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/layoutInstallHint"
                android:background="#99000000"></RelativeLayout>

            <RelativeLayout
                android:id="@+id/layoutInstallHint"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerInParent="true"
                android:background="#99000000">

                <com.spiceladdoo.views.LatoRegularTextView
                    android:id="@+id/installTextHint"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:layout_marginBottom="15dp"
                    android:layout_marginTop="5dp"
                    android:background="@color/spice_laddooblue"
                    android:paddingBottom="10dp"
                    android:paddingLeft="80dp"
                    android:paddingRight="80dp"
                    android:paddingTop="10dp"
                    android:text="INSTALL"
                    android:textAppearance="?android:attr/textAppearanceSmall"
                    android:textColor="#FFFFFF"
                    android:textSize="15sp"
                    android:textStyle="bold"
                    android:visibility="visible" />
            </RelativeLayout>

            <com.spiceladdoo.views.LatoRegularTextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
               android:layout_above="@+id/imageViewHintPinIcon"
                android:layout_centerHorizontal="true"
                android:text="Click on Button"
                android:textColor="@color/white"
                android:textSize="18sp" />

            <ImageView
                android:id="@+id/imageViewHintPinIcon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_centerHorizontal="true"
                android:layout_marginBottom="50dp"
                android:src="@drawable/hint_pin_down" />
        </RelativeLayout>
    </FrameLayout>

</RelativeLayout>

或者如果这不起作用,那么您可以将 scrollview 放在 cardview 中,然后将 webview 放在 card view 中

关于Android 系统 Webview 更新后的 Android WebView 渲染问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39746671/

相关文章:

java - 图像未以原始分辨率保存

javascript - 如何使用javascript将HTML用户输入数据存储到excel中

android - 如何使用 X509TrustManager 验证 android.net.http.SslCertificate?

android - 如何在 android 的本地 sqlite 数据库中存储 webview 响应?

android - 卡尔曼滤波器 - 指南针和陀螺仪

android - Spinner 不显示 UTF-8 字符

android - 保存到 Google Play Cloud 自动保存

javascript - 使用 socket.io 时 HTML 中出现 "Unexpected Token <"错误

html - css 框未显示在正确的位置(添加文档类型时)

android - 单击 WebView 上的事件坐标