禁用滚动型动作 [英] Disable ScrollView action

查看:262
本文介绍了禁用滚动型动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的申请,我行增加一个控件的宽度(通过拖动行至左/右),我已经在启用滚动型同样的活动。我需要禁用滚动视图的动作,当用户触摸行,并且当用户释放,应当启用。在滚动型应该在可视状态,但滚动视图的作用应该被禁用。请帮我解决这个问题。我试着这些,但没有他们的工作。

In my application i've a line for increasing the width of a widget(by dragging the line to right/left) and i've the ScrollView enabled in the same activity. I need to disable the scroll view action when the user touches the line and when user releases, it should be enabled. The ScrollView should be in visible state but the action of the scroll view should be disabled. Please help me in solving this problem. I've tried with these but none of them is working.

scroll.setEnabled(false); 
scroll.setFocusable(false); 
scroll.setHorizontalScrollBarEnabled(false); 
scroll.setVerticalScrollBarEnabled(false);

先谢谢了。

推荐答案

这可能是有点晚,但我遇到了同样的问题,所以我的解决方案是类似于上面,不得不关闭OnTouchListener如下:

This might be a bit late but I ran into the same problem so my solution is similar to above, had to disable the OnTouchListener as follows:

// Get the ScrollView
final ScrollView myScroll = (ScrollView) findViewById(R.id.display_scrollview);


// Disable Scrolling by setting up an OnTouchListener to do nothing
myScroll.setOnTouchListener( new OnTouchListener(){ 
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return true; 
    }
});


// Enable Scrolling by removing the OnTouchListner
tvDisplayScroll.setOnTouchListener(null);    

这工作了对待我!

这篇关于禁用滚动型动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆