intellignt_idiot intellignt_idiot - 5 months ago 80
Android Question

ScrollView with TextView with HTML inside another scrollView with clickable links, does not work

I have a scrollView , now I need to have a small scrollable textView inside this scrollView. I was able to do it with the below code :

scrollView.setOnTouchListener(new View.OnTouchListener() {

public boolean onTouch(View v, MotionEvent event)
{
findViewById(R.id.childScrollView).getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScrollView.setOnTouchListener(new View.OnTouchListener() {

public boolean onTouch(View v, MotionEvent event)
{

// Disallow the touch request for parent scroll on touch of
// child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});


Now textView scrolls inside child scrollview. I need to show HTML in this textView with clickable links. Now as soon as I give the property

txtView.setMovementMethod(LinkMovementMethod.getInstance())


the textView stops scrolling. I need scrolling and clickable links inside the textview.

How to change the above code so that I can keep the scrolling of the textView as well apply the setMovementMethod(LinkMovementMethod.getInstance()) on the textView.

Please let me know if this is possible.

Thanks

Answer

Because I could not find a solution to the above problem. I solved my problem by using WebView instead of TextView inside a scrollView.

Now to make the make webview scroll inside ScrollView ,I used the same code which I used earlier and the only change I did was to use WebView as ChildView for the ParentScrollView like this ;

webView.setOnTouchListener(new View.OnTouchListener() {

    public boolean onTouch(View v, MotionEvent event)
    {

// Disallow the touch request for parent scroll on touch of
// child view
        v.getParent().requestDisallowInterceptTouchEvent(true);
        return false;
    }
});

This way I was able to scroll the textview (which is now inside webview) inside a scrollView.