Question

I have a webView that is contained within a scrollView. Everything is then contained within a viewPager. When I fling to the next view page, the links that are in the middle of the page are being focused (highlighted with orange around the text). This causes the page to jump down to the nearest link.

Is there a way to disable links from being focusable on touch? I've tried all the settings for the webView such as focusable = false, clickable = false, focusable in touch mode = false, and nothing seems to be working.

Was it helpful?

Solution

I managed to do it programmatically like so:

WebView myWebView = (WebView) storyItem.findViewById(R.id.myWebView);
myWebView.setFocusableInTouchMode(false);
myWebView.setFocusable(false);

This makes the links non-focusable, which solved my problem!

OTHER TIPS

    webView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
Webview.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {                  
                        return true;
            }
        });

This prevents the webview from opening any links and will also allow you to navigate the page without problems

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top