Android programming uses LinearLayout and pullrefreshview to realize page up and page down function

This article describes the method of using LinearLayout and pullrefreshview to realize page up and page down function in Android programming. Share with you for your reference, as follows:

I've seen the Netease cloud reading client before. The articles in it can pull up and down and turn pages up and down. I feel that the experience effect is very good.

Similar effects are also required in the development of the company's new version project, but fortunately, the total number of pages that need to be pulled up and down can be known in advance in the project requirements. If you don't know the total number of pages in advance, like Netease, you can control the childview in LinearLayout.

A good memory is not as good as a bad pen. First write down the problem that I know the total number of pages in advance and turn pages up, down and down!

First, the layout is simply wrapped in a linear layout

The pullrefreshview is then wrapped in a for loop

Code Description: pulltorefreshproview here is an open source pull-down refresh control, which inherits a LinearLayout implementation. Online source code; Then, the rightadapter is a baseadapter. Get each view through the getview of the adapter, and then add the view to the child LinearLayout of pulltorrefreshproview from the inflator. Then set the pull-down callback interface for each pulltorefreshproview. The first one is not pulled down and the last one is not pulled down. Myonrefreshlistener here is a drop-down interface defined by itself

Then write the pull-down and pull-up logic in onfooter and onheader.

The key here is the realization of animation effect interaction.

Up code, up animation

Drop down animation

The consequence of these two animations is that each child LinearLayout of the last outermost LinearLayout package changes its own height and topmargin,

Therefore, you need to set the animationlistener for this animation, and then reset the height and topmargin of LinearLayout before the pull-down animation. The specific implementation depends on the specific situation.

PS: the core implementation method here is to control the height and topmargin of LinearLayout sub LinearLayout

More readers interested in Android related content can view the special topics of this site: summary of Android layout skills, summary of Android development animation skills, introduction and advanced tutorial of Android development, summary of Android view skills, summary of activity operation skills of Android programming, summary of Android resource operation skills, and Android control usage summary

I hope this article will help you in Android programming.

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
分享
二维码
< <上一篇
下一篇>>