【问题标题】:ScrollView with TextView with HTML inside another scrollView with clickable links, does not workScrollView with TextView with HTML inside another scrollView with clickable links,不起作用
【发布时间】:2016-06-29 12:58:30
【问题描述】:

我有一个 scrollView ,现在我需要在这个 scrollView 中有一个小的可滚动 textView。我可以用下面的代码做到这一点:

 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;
        }
    });

现在 textView 在子滚动视图中滚动。我需要在这个 textView 中显示带有可点击链接的 HTML。现在只要我给财产

txtView.setMovementMethod(LinkMovementMethod.getInstance())

textView 停止滚动。我需要在 textview 中滚动和可点击的链接。

如何更改上面的代码,以便我可以保持 textView 的滚动以及在 textView 上应用 setMovementMethod(LinkMovementMethod.getInstance())

如果可以,请告诉我。

谢谢

【问题讨论】:

    标签: android html scrollview textview android-scrollview


    【解决方案1】:

    因为我找不到上述问题的解决方案。 我通过在 scrollView 中使用 WebView 而不是 TextView 解决了我的问题。

    现在为了让 webview 在 ScrollView 中滚动,我使用了之前使用的相同代码,我所做的唯一更改是使用 WebView as ChildView ParentScrollView 像这样;

    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;
        }
    });
    

    通过这种方式,我能够在 scrollView 中滚动 textview(现在位于 webview 中)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-16
      • 2022-12-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多