InQBarna / TableFixHeaders

Android library that implements a table with fixed headers.
Apache License 2.0
818 stars 300 forks source link

How to disable diagonal scroll? need only one way scroll at a time. #91

Open kalpit-dave opened 8 years ago

kalpit-dave commented 8 years ago

The widget scrolls diagonally even with the slightest error of touch motion. How to make it scroll in one direction based on whether diffX is large or diffY is large. I attempted ScrollBy (diffX,0) and (0,diffY) but it malfunctions.

BraisGabin commented 8 years ago

If you want to changue this behaviour you must reimplement onTouchEvent in the class TableFixHeader.

mkaarthick commented 8 years ago

For this, Do I need to write my own onTouchEvent? Any snippets available?

BraisGabin commented 8 years ago

Yes, I recommend you to copy the original code and tune it.

kalpit-dave commented 8 years ago

To Do this you need to make changes at two places.. one at on UP and fling scroll. It works now like a charm with me. No big changes required.

mkaarthick commented 8 years ago

@kalpit-dave Can you please share the code snippet?

kalpit-dave commented 8 years ago

Here is the complete code for TableFixHeader.java file

`package com.inqbarna.tablefixheaders;

import java.util.ArrayList; import java.util.List;

import com.inqbarna.tablefixheaders.adapters.TableAdapter;

import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.content.Context; import android.database.DataSetObserver; import android.graphics.Canvas; import android.os.Build; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.VelocityTracker; import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.Scroller;

/**

AbdullahUsmani commented 6 years ago

@kalpit-dave thanks for the code. :)