开发者

android gallery "snappiness"

I am wondering if there'开发者_JAVA技巧s a way to increase the "snappiness" of the stock android gallery. in other words, I want the speed of a fling to drop off quicker than it does by default. a given fling should result in less scrolling and should stop quicker.

looking at the source, it looks like what I want is to change the value of ViewConfiguration.SCROLL_FRICTION, but as you can see that's a constant, and getting to the code makes use of that involves burrowing into private classes used by Gallery.

Any ideas?


I found something that gave the effect I want with little trouble. extend Gallery, and override onFling(),

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
        float velocityY) {
    return super.onFling(e1, e2, velocityX / 10, velocityY / 10);
}

Dividing the actual velocity by 10 gave me the effect I wanted.


You would have to override a TouchEvent listener in the gallery code to handle the flings the way you want. Although this may not be possible, and you might have to implement your own gallery. That is what I ended up doing because of how many customizations I needed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜