android 小知识点

时间:2014-06-30 14:50:17   收藏:0   阅读:205

小知识点总结

1.

android中MotionEvent.ACTION_CANCEL事件如何被触发?  

对于这个问题,android文档的说明很简短,想看明白很难。国外一网页说的还比较详细,写在这里分享给大家:

原文是这样的:

You receive this when a parent takes possession of the motion, for example when the user has dragged enough across a list view or scroll view that it will start scrolling instead of letting you press the buttons inside of it.  

意思是这样的:

当你的手指(或者其它)移动屏幕的时候会触发这个事件,比如当你的手指在屏幕上拖动一个listView或者一个ScrollView而不是去按上面的按钮时会触发这个事件。

2.

 

computeScroll:主要功能是计算拖动的位移量、更新背景、设置要显示的屏幕(setCurrentScreen(mCurrentScreen);)。

 

 

  重写computeScroll()的原因

 

  调用startScroll()是不会有滚动效果的,只有在computeScroll()获取滚动情况,做出滚动的响应

 

 

  computeScroll在父控件执行drawChild时,会调用这个方法

Scroller并不是View,它不负责任何显示工作,只是计算滚动过程。
    你在使用的时候可以用startScroll(int startX, int startY, int dx, int dy)指定起始位置和x/y轴位移
    然后调用computeScrollOffset()计算当前位置,返回"true"代表滚动中,返回"false"代表滚动结束
    最后调用getCurrX()/getCurrY()获得当前坐标,然后根据这个坐标绘制你的View

 

 

 

 

 

android 小知识点,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!