当前位置:首页 > 未命名 > 正文内容

Basic knowledges about Android View

u3blog8年前 (2016-03-09)未命名235

What View is

View is the parent class for every widget in Android. Widget mainly have two group,View and ViewGroup,all of them are View,the different is ViewGroup can have multiple children View. The layout our use is belong to ViewGroup.

The location parameters of View

How to know the view's position on screen? Android use four parameters to describe it. top,left,right,bottom The positive direction is right and down. But need notice, the position is depend on parent view, not depend on screen. There are two new parameters from Android 3.0,translationX,translationY, describe the displacement of view's left top from parent view.

MotionEvent and TouchSlop

MotionEvent means a serirs action after figure put down to screen,mainly have three kinds ACTION_DOWN ACTION_MOVE ACTION_UP TouchSlop is the minimum distance of slide, system will not recognize the action as a slide if distance is lower than it.

VelocityTracker,GestureDetector and Scroller

VelocityTracker can find out the slide speed GestureDetector is use to detect the gesture on screen Scroller could help to scroll view You can find they use in everywhere on internet so let's pass how to use.

View's slide

Slide view mainly have three ways 1.scrollTo/ScrollBy use to scroll view's content, such as listview move up or down 2.animation Simple to use,fit move the whole view to other place,but the click area not move, need some special handle 3.change the layoutparams not so easy to use, but have no obvious disadvantage

About Smooth Scroll

Smooth Scroll means when scroll there is a progress, not immediately. There are three ways to do it 1.Scoller in fect is use the invalidate() methods. 2.Animation can do some thing while scroll, also have scroll animation. 3.delay message send message in delay to scroll view.

扫描二维码推送至手机访问。

版权声明:本文由u3blog发布,如需转载请注明出处。

本文链接:https://u3blog.xyz/?id=263

分享给朋友:

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。