在webview中滚动滞后

时间:2016-09-22 05:33:08

标签: android scroll webview scrollview

我加载html内容,例如webView.loadData(mAdvertisement,“text / html; charset = utf-8”,null),我有ScrollView,其中包含ImageView,TextureView和WebView,当我滚动时我有问题那么它也是落后它不顺利工作,我也试过这个

webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);

        if (Build.VERSION.SDK_INT >= 19) {
            // chromium, enable hardware acceleration
            webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
        } else {
            // older android version, disable hardware acceleration
            webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        }

        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);

但仍然是它的原样!即使我进入了清单android:hardwareAccelerated="true",但它也一样,所以我该如何解决呢?

我的xml在

之下
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:customFont="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:background="#FFFFFF"
    android:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true">

    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="@dimen/divider_height"
        android:background="@color/gray_divider"
        android:visibility="gone"/>

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/view"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imgAdvertisement"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:visibility="gone"/>

            <TextureView
                android:id="@+id/videoTextUreView"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_gravity="center" />

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

                <WebView
                    android:id="@+id/webView"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:overScrollMode="never"
                    android:padding="@dimen/padding_10"
                    android:scrollbars="none" />

                <CustomTextView
                    android:id="@+id/txtNoDataFound"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_centerInParent="true"
                    android:gravity="center"
                    android:padding="@dimen/padding_10"
                    android:text="@string/no_data_found"
                    android:textColor="@android:color/holo_red_light"
                    android:textSize="@dimen/text_size_xlarge"
                    android:visibility="gone"
                    customFont:fontTextStyle="2" />
            </RelativeLayout>
        </LinearLayout>
    </ScrollView>
</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

从linearlayout移除背景可以解决滚动问题。现在它的黄油很滑