Android uses SwipeRefreshLayout control tiktok to do the video drop-down refresh effect.

Swiperefreshlayout (this control), let me introduce this control to you first:

1、 Brief introduction to swiperefreshlayout

• first look at the following official documents, which have been described in great detail.

@H_ 403_ 11@

Official document description

• here I'll give you a general explanation:

• you can use swiperefreshlayout to refresh the page when sliding vertically. It monitors the sliding of the interface by setting onrefreshlistener to refresh. You can also set whether swiperefreshlayout can be refreshed through some methods. For example: setrefreshing (true), expand the refresh animation. Setrefreshing (false) to cancel refreshing the animation. Setenable (true) drop-down refresh will not be available.

• in order to refresh the layout, you need to wrap slidable child controls in the layout, such as listview, and there can only be one child control.

• introduction and summary: the drop-down refresh can be realized by using swiperefreshlayout. The premise is that the layout needs to be wrapped with a sliding sub control, then onrefreshlistener is set in the code to monitor, and finally the data acquisition during refresh is set in the monitor. Because it is a new thing, if you want to use it, first upgrade the version of the support library to 19.1 or later.

2、 Introduction to main methods of swiperefreshlayout

Looking at the official documents, you can see that there are many methods. Here are only five frequently used methods.

• isrefreshing() • judge whether the current state is a refresh state.

•setColorSchemeResources(int... colorResIds)

• set the color theme of the drop-down progress bar. The parameters are variable parameters and resource ID. you can set a variety of different colors and display one color every turn.

•setOnRefreshListener(SwipeRefreshLayout.OnRefreshListener listener)

• to set listening, you need to rewrite the onrefresh () method. This method will be called when the top drop-down is used to implement the logic of requesting data, set the drop-down progress bar to disappear, and so on.

•setProgressBackgroundColorSchemeResource(int colorRes)

• set the background color of the drop-down progress bar, which is white by default.

•setRefreshing(boolean refreshing)

• set the refresh status. True indicates that the refresh is in progress, and false indicates that the refresh is cancelled.

Then I won't say much. Let's start directly:

design sketch:

@H_ 403_ 11@

activity_ Listview layout file

Activity code (listviewactivity)

summary

The above is a small volume to introduce Android using SwipeRefreshLayout control tiktok sound to do the video drop-down refresh effect, I hope it will help everyone. If you have any questions, please leave a message for me, Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>