how can I disable the scrolling of a Scrollview, by the user? I want to scroll it by code
To answer this question:
I've done some research, and the following works the best:
scroll.setOnTouchListener(new OnTouchListener()
{
public boolean onTouch(View v, MotionEvent event)
{
return true;
}
});
As parsed from my working code.
Related
I am using dragging feature for recycler view by using ItemTouch helper.
Dragging is working fine but I am unable to use onclick listener on the same view.
Below is my code:
holder.mainLayout.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
mCommunicator.onStartDrag(holder);
return false;
}
});
holder.mainLayout.setOnClickListener(v -> {
//LogManager.v(LOG_TAG,"touch:"+blnOnTouch);
holder.checkBox.performClick();
});
Please suggest me for this issue. Thanks in advance.
I am trying to add view for signature in scroll view,So i have disabled scroll view when we start signature gesture on signature view and it's working fine. But i am trying to enable the scroll on parent layout onTouchlistner. But due to other views,scroll is not working properly .
I tried the following link,but unable to solve my issue.
This is to disable scollview on gesture touchlistner
digitalSignView.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
//The following code is to disable scroll view on gesture touchListener.
ScView.setEnableScrolling(false);
return false;
}});
parentLayout.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
//The following code is to enable parent scroll view on outside touch event.
ScView.setEnableScrolling(true);
return false;
}
});
Please help me how to solve this issue.Thanks in advance.
Suppose that I have 100 item in my listView. When I scroll up and down, and I try to touch to stop the scrolling. But it's not work. It scroll until it reach the item of the first scroll touch.
Is it the phone problem or my app missing some implementing ?
public class OnTouchListner implements OnTouchListener{
#Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_DOWN)
{
businessResultListView.smoothScrollBy(0, 0);
return true;
}
return false;
}
}
and call it:
businessResultListView.setOnTouchListener(new OnTouchListner());
I have an UI issue like, some EditText s are there in LinearLayout ,and this linear layout is placed in scroll view . now what i want to do is edit text has large amount of data for seeing this data i have set android:scrollbars ="vertical" by this i'm able to see the scroll bar inside the edit text but the data is not scrolling. out side scrollbar is moving.how to fix this issue.
can anybody help me. Thanks in Advance.
This may help you....
parentScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
Log.v(TAG,"PARENT TOUCH");
findViewById(R.id.child_scroll).getParent().requestDisallowInterceptTouchEvent(false);
return false;
}
});
childScrollView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event)
{
Log.v(TAG,"CHILD TOUCH");
// Disallow the touch request for parent scroll on touch of child view
v.getParent().requestDisallowInterceptTouchEvent(true);
return false;
}
});
In your case 'parentScrollView' is your scrollView while childScrollView is your Linearlayout/EditText
Use yourEditTextView.setMovementMethod(new ScrollingMovementMethod());
I have an on touch listener for a webview, but it has a bad effect on the functionality of the webview, so I am wondering if there is anyway to removed the on touch listener after the initial interaction?
webView.setOnTouchListener(null);
So in you activity you would set your overridden onTouchListener:
mWebView.setOnTouchListener(new View.OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent event) {
v.setOnTouchListener(mWebView.mOnTouchListener);
return false;
}
});
And you would have to make a new class, extending WebView. And within it you would define an OnTouchListener.
public final OnTouchListener mOnTouchListener = new OnTouchListener() {
#Override
public boolean onTouch(View v, MotionEvent rawEvent) {
return false;
}
};
Setting the ontouchlistener to null doesn't reset it to the default definition. You still have to provide an actual listener.
I was looking for help online and got to this post.
When I did
myView.setOnTouchListener(null);
my myView stopped responding to the onTouch.