GetContentHeight()无法正常工作无法正常、工作、GetContentHeight

2023-09-07 13:56:00 作者:△我是疯子,但疯的真实

我想要检索的WebView内容的高度。它包含一个HTML字符串。 问题是,getContentHeight()总是返回相同的值(392),无论多久HTML的字符串。

解决方案

我有这个问题,getContetHeight()以及。 首先在 WebViewClient.OnPageFinish()回调的内容高度是不是已经设置成我就是这样做是pretty的rought解决方案。

 处理程序H;
可运行scroll_updater =新的Runnable(){
    @覆盖
    公共无效的run(){
        如果(Thread.interrupted())
            返回;

        如果(lyrics.getContentHeight()== 0)
            h.postDelayed(此,100);

        setLyricsScroll();
    }
};
 

I'm trying to retrieve the height of a webview's content. it contains a html-string. The problem is that getContentHeight() returns always the same value (392), no matter how long the html-string is.

解决方案 MacBook键盘无法正常工作 故障排除指南

I had this problem with getContetHeight() as well. First in the WebViewClient.OnPageFinish() callback the content height wasn't already set so what I did it's pretty rought solution.

Handler h;
Runnable scroll_updater = new Runnable() {
    @Override
    public void run() {
        if(Thread.interrupted())
            return;

        if(lyrics.getContentHeight() == 0)
            h.postDelayed(this, 100);

        setLyricsScroll();
    }
};