Mainactivity as follows:Package Cc.cn;import Android.os.bundle;import Android.view.view;import android.view.view.onclicklistener;import Android.widget.button;import android.app.activity;/** * Demo Description: * Scroller Use example-let the control pan across the screen * reference: * HTTP://BLOG.CSDN.N et/c_weibin/article/details/7438323 * Thank you very much * * NOTE: * 1 Set the width of the Cc.cn.LinearLayoutSubClass control in the layout to "Fill
Mainactivity such as the following:Package Cc.cn;import Android.os.bundle;import Android.view.view;import android.view.view.onclicklistener;import Android.widget.button;import android.app.activity;/** * Demo Description: * Scroller Use Demo sample-let the control pan across the screen * * reference information: * Http://blog.cs dn.net/c_weibin/article/details/7438323 * Thank you very much * * NOTE: * 1 Set the width of the Cc.cn.LinearLayoutSubClass c
(mscrollx + x, m
scrolly + y);
}
//...
}
So, at any moment, we can get the offset position of the view/viewgroup, that is, call the Getscrollx () method and the Getscrolly () method
Introduction to the Scroller class
in the first time to see launcher slide screen, I was scroller class of learning feel very egg pain, completely lost the desire to continue research. Today, there
In android learning, Action interaction is an important part of software, and Scroller is a class that provides the drag effect. On the internet, for example, some Launcher screens can be implemented through this class ..The SlidingLayer, an open-source library for side navigation, is actually implemented using the scroroller class: GITHUB, which is not the Library mentioned below, it is the
the right, then click the Scrollto button will have no effect, the interface will not continue to scroll, only click on the Scrollby button interface will continue to scroll, And constantly click the Scrollby button interface will scroll down together.
Scroller class
From the above example, the results show that the Scrollto ()/scrollby () method is used to offset a view to the specified coordinates (X,Y), the whole process is a direct jump, withou
Smooth scrolling effect of view
What is the realization of the smooth scrolling effect of view, for example, a view from the time we specify from one position to another position, we use the Scroller class can be used to achieve uniform rolling, can be accelerated after deceleration, can first slow down after acceleration and so on, Instead of the instantaneous movement of the effect, so scroller can help
Reference to:http://blog.csdn.net/a910626/article/details/51548840What is a. scroller?
The Scroller class in Android is a helper class to implement view smooth scrolling. Usually used in custom view, a private member Mscroller = new Scroller (context) is defined in view. Setting the Mscroller scrolling position does not cause the view to scroll, usually using
In the article "Summary of methods for realizing the movement of view", several methods to realize the movement of view are introduced: Setlayoutparams (), ScrollTo () and Scrollby (), layout (), Offsetleftandright () and Offsettopandbottom (), displacement animations and property animations. In these methods, only the displacement animation and property animation is smooth scrolling, the other methods are instantaneous to move the view to the target location, the visual experience is not very g
What does the scroller in Android ViewGroup have to do with Computescroll?
Answer: There is no direct relationship.
Knowing the answer, does not mean that the following is not necessary to see, if the ViewGroup custom control is not interested, you can not see.
What exactly is 1.Scroller?
A: Scroller is just a calculator that provides interpolation calculatio
duration)Scroll, StartX, starty to start scrolling position, dx,dy for scrolling offset, duration for time to complete scrollingMscroller.computescrolloffset ()A return value of Boolean,true indicates that scrolling has not been completed and false indicates that scrolling is complete. This is a very important method, usually placed in View.computescroll (), to determine whether scrolling is over or not.The specific use of scroller has been useful in
In the previous article introduced the view class of Scrollto and Scrollby two methods, the two methods are not very familiar with the friends can first look at "their own definition of view and ViewGroup"Scrollto and Scrollby, while achieving the offset of the view, did not have a better control of the moving process, the movement is instantaneous. The Scroller class is designed to solve problems.Open the Scrolle
Android custom controls (Scroller)
First lookThe implementation method inherited from ViewGroup requires us to measure and layout ourselves to achieve sliding effect and handle sliding conflicts,The general idea of customizing ViewGroup is to override the onMeasure method, call measureChild in the onMeasure method to measure the child View, and then call setMeasuredDimension to measure the size of the Child View. Then rewrite the onLayout method and c
1. PrefaceThrough the Scrollto/scrollby method provided by the view itself to achieve sliding, the process is instantaneous, want to achieve elastic sliding, need to use scroller to achieve. The Scroller class in Android is a helper class to implement view smooth scrolling. Usually used in custom view, a private member Mscroller = new Scroller (context) is define
1. Knowledge points
Before you know the Scorller class, you should know that the view's Scrollto (int x, int y)/scrollby (int x, int y), what is the view coordinates, and what is the layout coordinates. Then we look at the source code of Scroller.
Scoller is generally used in custom viewpublic class Scroller {private int mstartx; Starting coordinate point, x-axis direction private int mstar
Ext.: http://ipjmc.iteye.com/blog/1615828The Scroller class in Android is a helper class to implement view smooth scrolling. Usually used in custom view, a private member Mscroller = new Scroller (context) is defined in view. Setting the Mscroller scrolling position does not cause the view to scroll, usually using Mscroller to record/calculate the position of the view scroll, and then rewrite the view's Com
. Swipe up, and the content scrolls down, view.getscrolly () gets a positive valueIn short, the direction of the finger slide is opposite to the content scrolling, and the interface effect of the ListView and Horizontalscrollview is knownAfter you get the value, you can scroll through (new Scroller ()). Startscroll (int startX, int starty, int dx, int dy) method scrolls the content to the appropriate locationTo perform a
The Scroller class in Android is a helper class to implement view smooth scrolling. Usually used in custom view, a private member Mscroller = new Scroller (context) is defined in view. Setting the Mscroller scrolling position does not cause the view to scroll, usually using Mscroller to record/calculate the position of the view scroll, and then rewrite the view's Computescroll () to complete the actual scro
Mainactivity as follows:Package Cc.cn;import Android.os.bundle;import Android.view.view;import android.view.view.onclicklistener;import Android.widget.button;import android.app.activity;/** * Demo Description: * Scroller Use example-let the control pan across the screen * reference: * HTTP://BLOG.CSDN.N et/c_weibin/article/details/7438323 * Thank you very much * * NOTE: * 1 Set the width of the Cc.cn.LinearLayoutSubClass control in the layout to "Fill
This article translated from: http://developer.android.com/reference/android/widget/Scroller.html
Inheritance relationship
Java. Lang. Object
|____ Android. widget. scroller
Class Overview
This class encapsulates rolling processing. In its constructor, you can pass the rolling duration and specify the maximum time required by the Rolling animation. During this period, the rolling processing will automatically move them to the final stage. If the compu
The Scroller class in Android is a helper class to implement view smooth scrolling. Usually used in custom view, a private member Mscroller = new Scroller (context) is defined in view. Setting the Mscroller scrolling position does not cause the view to scroll, usually using Mscroller to record/calculate the position of the view scroll, and then rewrite the view's Computescroll () to complete the actual scro
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.