继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

笔记,View方法: computeScroll 、onLayout 、onDraw 、onTouchEvent

桃花长相依
关注TA
已关注
手记 113
粉丝 15
获赞 56

自定义View从实现ondraw开始;

创建(onFininshInflate等)/布局(onMeasure,onLayout,onSizeChanged)/绘制/

事件处理(onTrackballEvent,onTouchEvent等)/

焦点(onFocusChanged,onWindowFocusChandge等)/

绑定(onAttachedToWindow,onDetachedFromWindow,onWindowVisibilityChanged等);

  framework负责调用onmeasure -> onlayout -> ondraw;程序中不能直接调用(除非实现了ViewGroup);

View.setMeasuredDimension必须由View.onMeasure()调用;View.layout();  //为View指定尺寸和位置。

  View Position:getRight()相当于getLeft()+getWidth(); getMeasureWidth和getWidth的差距在padding;

  View Layout:重新布局调requestLayout方法。   

  View Draw:重绘制调invalidate方法;framework不绘制无效区域的view; 

  View Focus Handling:setFocusable()和setFocusableInTouchMode(); 移动指定下一焦点newtFocusDown/nextFocusLeft/nextFocusRiht/nextFocusUp;获取焦点requestFocus();

  View Tags:存储额外数据,不是唯一标识。 

  View Security:setFilterTouchesWhenObscured()和onFilterTouchEventForSecurity(); 被遮挡时,对事件进行过滤/或者 屏蔽事件;

View的computeScroll():Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. 

This will typically be done if the child is animating a scroll using a {android.widget.Scroller Scroller} object.

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

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

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

--------------------------------------------------

http://blog.csdn.net/liu31187/article/details/11930419

原文链接:http://www.apkbus.com/blog-328402-58768.html

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP