Android ListView is pulled to the top/bottom, resilience and reset like a rubber band, androidlistview
Source: Internet
Author: User
Android ListView is pulled to the top/bottom, resilience and reset like a rubber band, androidlistview
"Android ListView is pulled to the top/bottom, resilience and reset like a rubber band"
When the Android ListView is pulled to the top or bottom, a "flashing" effect will appear in the gap between the top/bottom edges, indicating that the ListView has reached the top/bottom and can no longer move.
This is an interactive design where the Android native ListView is pulled to the top/bottom. There are many options for interaction design. Android 5.0 changed the interactive design of ListView into "a rippling halo".
Among the many interactive design schemes, one of the interactive design is like this: When the ListView is pulled to the top or bottom, the ListView will be like a rubber band, and the ListView will show a damping effect. When the user releases the ListView, the ListView will automatically be like a rubber band.
To achieve the above-mentioned interactive effect on Android, the method overScrollBy() can be achieved by rewriting ListView.
Now give an example, step by step implementation.
First, I need to write a ZhangPhilListView inherited from Android ListView:
// The most critical place.
//Support to SDK8 needs to add @SuppressLint("NewApi").
@SuppressLint("NewApi")
@Override
protected boolean overScrollBy(int deltaX, int deltaY, int scrollX,
int scrollY, int scrollRangeX, int scrollRangeY,
int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) {
return super.overScrollBy(deltaX, deltaY, scrollX, scrollY,
scrollRangeX, scrollRangeY, maxOverScrollX, newMaxOverScrollY,
isTouchEvent);
}
}
Then use it directly in my layout file activity_main.xml like using Android's ListView:
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.