Are there other ways to implement a Horizontal ListView in Android with bouncing/ recoil effect after it reaches the end of the list? I used this HorizontalListView. Then since i'm also implementing a bouncing effect in my ListView (vertical)..I used this:
public class BounceListView extends ListView
{
private static final int MAX_Y_OVERSCROLL_DISTANCE = 100;
private Context mContext;
private int mMaxYOverscrollDistance;
public BounceListView(Context context)
{
super(context);
mContext = context;
initBounceListView();
}
public BounceListView(Context context, AttributeSet attrs)
{
super(context, attrs);
mContext = context;
initBounceListView();
}
public BounceListView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
mContext = context;
initBounceListView();
}
private void initBounceListView()
{
//get the density of the screen and do some maths with it on the max overscroll distance
//variable so that you get similar behaviors no matter what the screen size
final DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
final float density = metrics.density;
mMaxYOverscrollDistance = (int) (density * MAX_Y_OVERSCROLL_DISTANCE);
}
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent)
{
//This is where the magic happens, we have replaced the incoming maxOverScrollY with our own custom variable mMaxYOverscrollDistance;
return super.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY, maxOverScrollX, mMaxYOverscrollDistance, isTouchEvent);
}
}
So, what i thought was since this class was used to implement a recoil/bounce effect, why not modify this for my HorizontalListView..so i created a class similar to this but extended it to HorizontalListView then change instead of y
to x
. But it didn't work. One thing also, overScrollBy
is not defined in AdapterView (since HorizontalListVIew extends to this.)
Are there ways to implement a horizontal list with bounce? or are there open source libraries that could be of help?
Any help is greatly appreciated.