滚动(选框)时,Web视图中的内容会缩小并消失?

时间:2018-04-05 14:27:35

标签: android html android-webview marquee

我正在使用选框效果实现Web视图。我有一个字符串,并通过执行以下代码将其作为HTML内容加载。

String test= "this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test. this is a test.";

            summary = "<html><FONT ><marquee behavior='scroll' direction='left' scrollamount=" + speed + ">"
                    + test + "</marquee></FONT></html>";

我在网页视图中加载此内容如下所示。

webviewScroll.loadDataWithBaseURL(null, summary, "text/html", "UTF-8", null);

以下代码使文字显示在页面的中间

webviewScroll.setPictureListener(new WebView.PictureListener(){         int previousHeight;

    @Override
    public void onNewPicture(WebView w, Picture p) {
        int height = w.getContentHeight();
        webviewScroll.scrollTo(0, height / 2);

        webviewScroll.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                return (event.getAction() == MotionEvent.ACTION_MOVE);
            }
        });
    }
});

问题是,当内容即将完成时,它会缩小并最终消失。问题只发生在内容即将完成且内容很大的情况下。小内容不是这样发生的。

下面我附上了网页视图中缩小内容的截图。

enter image description here

下面的图片显示了内容的选框,而不是在开始时在网页视图中缩小。

enter image description here

有人知道为什么会这样吗?

0 个答案:

没有答案