Android controls ScrollView Sliding Speed

Source: Internet
Author: User

 

Preface

Because the materials of different Android tablet touch screens are different, the sliding effect may be different. Some of them are sensitive and some are slow. Here we have met the requirement to control the sliding speed...

 

Statement

You are welcome to repost, but please keep the original source of the article :)

Blog: http://www.cnblogs.com

Farmer's uncle: http://over140.cnblogs.com

 

Body

I searched for the ScrollView document and found no directly set attributes and methods. Here we use inheritance to achieve this purpose.

/**
* Fast/slow sliding ScrollView
* @ Author: farmer's uncle
*
*/
Public class SlowScrollView extends ScrollView {

Public SlowScrollView (Context context, AttributeSet attrs, int defStyle ){
Super (context, attrs, defStyle );
}

Public SlowScrollView (Context context, AttributeSet attrs ){
Super (context, attrs );
}

Public SlowScrollView (Context context ){
Super (context );
}

/**
* Slide event
*/
@ Override
Public void fling (int velocityY ){
Super. fling (velocityY/4 );
}
}

Code Description:

The focus is "velocityY/4", which means that the sliding speed slows down to 1/4. Here, you can speed up or slow down the sliding speed as needed.

 

End

It would be a pleasure to solve abnormal demands.

Related Article

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.