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.