Android WebView JellyBean -> Should not happen: no rect-based-test nodes found

前端 未结 8 1592
南旧
南旧 2020-11-30 20:32

My application is using a lot of webviews which are lying in fragments which are hold by a ViewPager.

Whenever i swipe through the app on my Galaxy Nexus with Jelly

相关标签:
8条回答
  • 2020-11-30 21:27

    I had this exact issue. The problem is exactly what Rahul Dole said in his answer above.

    I spend a few days on this trying tons of different things. I noticed that when the orientation changed that the visible WebView onLongClick worked again...so I came up with this little gem. Indeed its very hacky but it works!

    Use this in your class that extends WebView:

    @Override
    public boolean onTouchEvent(MotionEvent event) {
    
        if (event.getAction() == MotionEvent.ACTION_DOWN){
    
            int temp_ScrollY = getScrollY();
            scrollTo(getScrollX(), getScrollY() + 1);
            scrollTo(getScrollX(), temp_ScrollY);
    
        }
    
        return super.onTouchEvent(event);
    }
    
    0 讨论(0)
  • 2020-11-30 21:28

    Have the same problem with JellyBean and ViewPager + fragments that contains WebViews. And all OK with the same code running on Android 2.2, so I think this is a bug in JB WebView implementation.

    On JB only the first shown fragment with WebView works right, without errors "Should not happen .." in the log, and getHitTestResult() calls returns correct values. Swiping to the next pages, I got errors in log and getHitTestResult() returns only zeroes and nulls.

    Now I found only one solution to create fragments with empty containers and create WebViews, setup they and load data only when current fragment becomes active in the ViewPager. In this case WebView works as needed. But, unfortunately, this completely breaks an idea of smooth swiping pages in the ViewPager.

    Have the last idea, tomorrow will try to replace ViewPager's fragments to compound views. Little chances, but I'll let you know if results will be successful.

    0 讨论(0)
提交回复
热议问题