Android Gallery Full width, no gap
I need to build something like a stream for my android app (like pulse) I tried several horizontalListview or H开发者_开发技巧orizontalScrollView but it's not smooth at all!
The smoother widget I found is the gallery.
I successfully tweaked it to right align:
http://cl.ly/0a3Q002u3H1f3w2l0g2e
My problem is when you scroll max to the right. It looks like stream #3. Is there a way change this to avoid the gap on the right ?
Maybe to changing the maximum selectable position (# of elements - 4 in my case)
Thank you.
Actually I use this one https://github.com/vieux/Android-Horizontal-ListView
I found the problem about smoothness. The vertical listview shouldn't react when we are already scrolling a stream horizontally.
You could try something like
public class GalleryChild extends Gallery {
...
@Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (getSelectedItemPosition() >= getChildCount() - BUFFER) {
setSelection(getChildCount() - BUFFER, true);
/** Eat the event. */
return true;
} else return super.onScroll(e1, e2, distanceX, distanceY);
}
精彩评论