ITPub博客

首页 > IT职业 > IT图书 > 笔记,View方法: computeScroll 、onLayout

笔记,View方法: computeScroll 、onLayout

IT图书 作者:jmj83 时间:2021-09-09 10:07:58 0 删除 编辑

自定义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

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/1065/viewspace-2817079/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-15

  • 博文量
    0
  • 访问量
    467