本文介绍了如何使用overscroll功能的列表视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Android的新Overscroll功能姜饼介绍并发现了一些更有趣的事情。该功能使AA视图滚动超出了它的极限,然后反弹(几乎完全一样的iOS)之类的内置的框架,但只是被隐藏了。
解决方案
您可以试试这个它给。您的问题的解决方案。
滚动视图=(滚动型)findViewById(R.id.scr);
内容查看=(ViewGroup中)findViewById(R.id.r2);
scrollView.setOnTouchListener(新ScrollPager(滚动视图,内容查看));
scrollView.post(新的Runnable(){
公共无效的run(){
scrollView.scrollTo(0,contentView.getPaddingTop());
}
});
为此,你需要的scroolerPager类。它来到这里,
公共类ScrollPager实现OnTouchListener
公共ScrollPager(滚动型aScrollView,ViewGroup中aContentView)
{
mScrollView = aScrollView;
mContentView = aContentView;
滚动=新的滚轮(mScrollView.getContext(),新OvershootInterpolator());
任务=新的Runnable()
{
公共无效的run()
{
scroller.computeScrollOffset();
mScrollView.scrollTo(0,scroller.getCurrY());
如果(!scroller.isFinished())
{
mScrollView.post(本);
}
}
};
}
Android's new Overscroll functionality introduced in Gingerbread and discovered some more interesting things.The functionality to make a a view scroll beyond its limits and then bounce back (almost exactly like iOS) is sort of built into the framework, but just hidden.
解决方案
You can try this it give. you the solution for your problem.
scrollView = (ScrollView) findViewById(R.id.scr);
contentView = (ViewGroup) findViewById(R.id.r2);
scrollView.setOnTouchListener(new ScrollPager(scrollView, contentView));
scrollView.post(new Runnable() {
public void run() {
scrollView.scrollTo(0, contentView.getPaddingTop());
}
});
for this you need the scroolerPager Class. get it here,
public class ScrollPager implements OnTouchListener
public ScrollPager(ScrollView aScrollView, ViewGroup aContentView)
{
mScrollView = aScrollView;
mContentView = aContentView;
scroller = new Scroller(mScrollView.getContext(), new OvershootInterpolator());
task = new Runnable()
{
public void run()
{
scroller.computeScrollOffset();
mScrollView.scrollTo(0, scroller.getCurrY());
if (!scroller.isFinished())
{
mScrollView.post(this);
}
}
};
}
这篇关于如何使用overscroll功能的列表视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!