listView实现阻尼效果
2015-05-14 17:26
225 查看
自定义类继承ListView public class BounceListView extends ListView{ private static final int MAX_Y_OVERSCROLL_DISTANCE = 200; 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); } } 布局 <com.example.li.BounceListView android:id="@+id/listView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="none" />
相关文章推荐
- 上下拉伸图片-第三方开源-PullToZoomListViewEx 实现阻尼效果
- ListView 实现阻尼回弹效果 并去除边缘阴影
- Android使用最简单的方式实现ListView 拉出回弹效果,阻尼效果(一)
- Android回弹阻尼效果的简单实现,非基于ListView,ScrollView
- Android UI设计之<十>自定义ListView,实现QQ空间阻尼下拉刷新和渐变菜单栏效果
- Android UI设计之<十>自定义ListView,实现QQ空间阻尼下拉刷新和渐变菜单栏效果
- 自定义控件(24)---自定义控件之setMargins、嵌套ScrollView并且实现ListView阻尼效果
- android 中如何实现listview向左边滑动跟微信删除好友一样的效果?
- SwipeListView 详解 实现微信,QQ等滑动删除效果
- 自定义listview 实现仿qq聊天列表左滑删除效果
- android 自定义ScrollView实现背景图片伸缩(阻尼效果)
- Android 使用Scroller实现绚丽的ListView左右滑动删除Item效果
- SwipeListView 详细介绍(实现微信,QQ等滑动删除效果)
- Android自定义View之ListView实现时间轴效果:我只是个送快递的。
- 点击侧滑任何一个 菜单项,请求网络数据展示在主界面的xlistview中且实现下拉刷新效果和上拉加载的分页加载数据效果
- android ListView各种效果实现总结,持续更新...
- ExpandableListView实例(二)_两种方式实现QQ中组后面显示子条目数量效果
- 一行代码实现去除ListView,RecycleView等可滑动控件的光晕效果
- SwipeListView 详解 实现微信,QQ等滑动删除效果
- Android基于ListView实现类似QQ空间的滚动翻页与滚动加载效果