Android's ListView Bounce Effect

Source: Internet
Author: User

Inherit the listview, override the Overscrollby method, call the Super.overscrollby () method, replace the maxoverscrolly parameter

ImportAndroid.content.Context; ImportAndroid.util.AttributeSet; ImportAndroid.util.DisplayMetrics; ImportAndroid.widget.ListView; /*** Elastic listview. * @authorE*/   Public classFlexilistviewextendslistview{//Initial pull y-axis direction distance    Private Static Final intmax_y_overscroll_distance = 100; //Contextual Environment    PrivateContext Mcontext; //the distance on the y-axis can actually be pulled up and down    Private intmmaxyoverscrolldistance;  PublicFlexilistview (Context context) {Super(context); Mcontext=context;      Initbouncelistview (); }             PublicFlexilistview (Context context, AttributeSet attrs) {Super(context, attrs); Mcontext=context;      Initbouncelistview (); }             PublicFlexilistview (context context, AttributeSet attrs,intDefstyle) {          Super(context, attrs, Defstyle); Mcontext=context;      Initbouncelistview (); }            Private voidInitbouncelistview () {FinalDisplaymetrics metrics =mcontext.getresources (). Getdisplaymetrics (); Final floatDensity =metrics.density; Mmaxyoverscrolldistance= (int) (Density *max_y_overscroll_distance); } @Overrideprotected BooleanOverscrollby (intDeltaX,intDeltaY,intSCROLLX,intScrolly,intScrollrangex,intScrollrangey,intMAXOVERSCROLLX,intMaxoverscrolly,Booleanistouchevent) {           //The essence of implementation is to dynamically change the value of the maxoverscrolly here .        return Super. Overscrollby (DeltaX, DeltaY, Scrollx, scrolly, Scrollrangex, Scrollrangey, MAXOVERSCROLLX,        Mmaxyoverscrolldistance, istouchevent); }        }

Android's ListView Bounce Effect

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.