Basic knowledges about Android View

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.


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

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.

A software developer

Leave a Comment

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.