In many news projects , Let's slide down the list to see the news , Generally, drop-down refresh will be implemented , Pull up to load more functions , Sometimes we slide to the bottom , At this point, it is very troublesome to refresh or pull up to the top , So you need to click the top , Many projects have this design , So how to achieve it ?

The following provides an implementation idea , It's not too much trouble , Direct code :
public class GoTopScrollView extends ScrollView implements
View.OnClickListener { // Top button private ImageView goTopBtn; public
GoTopScrollView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle); } public void setScrollListener(ImageView
goTopBtn) { this.goTopBtn = goTopBtn; this.goTopBtn.setOnClickListener(this); }
@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) {
super.onScrollChanged(l, t, oldl, oldt); // Sliding distance exceeds 200px, The up button appears if(t > 200) {
goTopBtn.setVisibility(View.VISIBLE); } else {
goTopBtn.setVisibility(View.GONE); } } @Override public void onClick(View v) {
if(v.getId() == R.id.imageView) { this.smoothScrollTo(0, 0); } } }

After that, the user-defined ScrollView Embedded in ListView Outside , The method of use is as follows : stay ScrollView Add a ImageView,ScrollView It's essentially a FrameLayout,setCrollListener(imageView) that will do

Technology
©2020 ioDraw All rights reserved
0.96OLED display -4 Line SPI explain C++11 of std::function,std::bind,std::placeholdersJavaScript study ( Function declaration and parameters )QTabWidget Style sheet settings The project passed idea Package and publish to tomcat The server postman Interface test get timestamp and MD5 encryption react Background management configuration route and sidebar :python Simple game code -10 Minutes Python Write a snake game , simple You know? Python What does the foundation include ? Learn something ?10 individual Python Introduction to crawler